[Cmake] Setting Variables in CMAKE

Linton, Tom tom.linton at intel.com
Mon, 26 Apr 2004 13:38:21 -0700


Brad and Bill: thanks for the replies. This does work
for me now.=20

Tom


-----Original Message-----
From: William A. Hoffman [mailto:billlist at nycap.rr.com]
Sent: Monday, April 26, 2004 12:58 PM
To: Linton, Tom; cmake at www.cmake.org
Subject: Re: [Cmake] Setting Variables in CMAKE


There really should not be any commands before the PROJECT command,
and after the project command CMakeDetermineSystem.cmake will have
been included automatically.

I just tried this and it worked:

PROJECT(TRY)
SET(MYFLAG "default")
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
       SET(MYFLAG "linuxValue")
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
SUBDIRS(a b) # if the system is Linux then MYFLAG should be set in both =
a and b.


What version of cmake are you using? =20

-Bill


At 11:13 PM 4/22/2004, Linton, Tom wrote:
>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
>
>_______________________________________________
>Cmake mailing list
>Cmake at www.cmake.org
>http://www.cmake.org/mailman/listinfo/cmake=20