Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake - set_property could not find CACHE variable

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?

like image 950
El Marce Avatar asked Jan 28 '26 23:01

El Marce


1 Answers

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.

like image 147
Tsyvarev Avatar answered Feb 01 '26 02:02

Tsyvarev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!