CMake - set_property could not find CACHE variable

2.1k views Asked by At

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.


I'm trying to create a dropdown list in CMake GUI following the instructions in here and here

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)

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 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?

1

There are 1 answers

0
Tsyvarev On BEST ANSWER

You may check value of variable TARGET_ARCHITECTURE using message() and you will found CACHE is a part of that value.

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.