CMake-set_property找不到CACHE变量 [英] CMake - set_property could not find CACHE variable
问题描述
免责声明::我知道问题。但是,OP的需求因我而异:他真正想要的是将应用程序移植到Linux,因此答案就在那行,而不是回答我想知道的:错误原因。
Disclaimer: I'm aware of this question. However, The OP's needs are different to mine: what he actually wants is to port an app to Linux and therefore the answers go in that line, not answering what I want to know: the reasons of the error.
所以我有一个非常简单的CMakeLists.txt:
So I have this very simple CMakeLists.txt:
cmake_minimum_required(VERSION 3.6)
project(datasetprograms)
set(CMAKE_CXX_STANDARD 11)
#LINES TO MAKE THE GUI DROP-DOWN:
set(TARGET_ARCHITECTURE "arm" CACHE STRING "Architecture to compile to")
set_property(CACHE TARGET_ARCHITECTURE PROPERTY STRINGS arm x86)
#Add subdirectories for each project
add_subdirectory(helloworld)
基本上,我只是按照说明进行了复制和粘贴。但是,不是在CMake GUI中有一个不错的下拉菜单,而是出现以下错误:
Basically I just copied and pasted, following the instructions. However, instead of having a nice drop-down in the CMake GUI, I got the following error:
CMake在CMakeLists.txt中出错: 9(set_property):set_property可能
找不到CACHE变量TARGET_ARCHITECTURE。也许尚未创建
CMake Error at CMakeLists.txt:9 (set_property): set_property could not find CACHE variable TARGET_ARCHITECTURE. Perhaps it has not yet been created
问题:我在做什么错了?
Question: What I'm doing wrong?
推荐答案
您可以使用<$ c $检查变量 TARGET_ARCHITECTURE
的值c> message(),您会发现 CACHE 是该值的部分。
You may check value of variable TARGET_ARCHITECTURE
using message()
and you will found CACHE is a part of that value.
这是因为您在 set()
命令中使用了不常见的双引号(
),但是特定于语言的(
)。因此CMake将 set()
命令视为 CACHE 'd。那是错误消息的原因。
This is because you use in set()
command double quotes which are not common ones ("
) but language-specific ("
). So CMake treats set()
command as not CACHE'd one. That is a reason of the error message.
这篇关于CMake-set_property找不到CACHE变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!