[Cmake] Setting Variables in CMAKE
Linton, Tom
tom.linton at intel.com
Thu, 22 Apr 2004 17:10:37 -0700
I have a source tree with a top level CMakeLists.txt file that contains
something like:
INCLUDE(${CMAKE_ROOT}/Modules/CMakeDetermineSystem.cmake)
SET(MYFLAG "defaultValue")
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
SET(MYFLAG "linuxValue")
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
PROJECT(TRY)
SUBDIRS(a b)
The behavior of CMAKE is that (1) in the top-level CMakeLists.txt the =
variable
"MYFLAG" gets set to "linuxValue" wherease (2) in the subdirectories
"MYFLAG" is left at "defaultValue".=20
I tried changing the SET command like:=20
SET(MYFLAG "defaultValue" CACHE INTERNAL "myflag")
but this had no effect.
I want to set variables at top-level based on the system name and have =
these
variables propagate to the subdirectories and it seems like what I'm =
doing is
correct, according to section 3.4 in the CMake book, which say that =
variable
scope is limited to a CMakeList file and any subdirectory CMakeList =
files.
This seems like a really basic thing to want to do. Any suggestions on
what's going wrong?
Thanks
Tom