I have a CMAKE variable I define on the command line with: “-DFOO=host”
Then in my CMAKEFILE – I want to treat the name “FOO=host” as a generic for the current host, ie: ON Linux -DFOO=host would be come set(FOO “linux”), or set(FOO “Darwin”) for a Mac.
However – it seems I cannot redefine the variable FOO using set.
I would have expected an ERROR – ie: “Error cannot set FOO” but I get no error.
My test case is sort of simple:
message("FOO= ${FOO}")
if( "${FOO}" STREQUAL "host" )
if( ${CMAKE_SYSTEM_NAME} strequal "linux" )
set( FOO "linux_host" )
endif()
endif()
message("FOO= ${FOO}"