[CMake] global variable vs cache variable

Michael Wild themiwi at gmail.com
Tue Nov 22 10:35:20 EST 2011


On 11/22/2011 02:14 PM, t m wrote:
>> Use the cache only if the values need to be persistent. Otherwise I
>> recommend using a GLOBAL property. See set_property() and get_property().
>>
>> Michael
> 
> Thank you Michael. Looks good. So let me summarize. The workflow
> should looks like follow:
> 
> 1. Top Level  CMakeLists.txt:
> add_subdirectory( foo )
> 
> 2. Level 2 foo/CMakeLists.txt
> set_property ( GLOBAL P_A PROPERTY "some value")

that should read:

set_property(GLOBAL PROPERTY P_A "some value")

> 
> 3. Level 1 CMakeLists.txt
> get_property ( VAR_A GLOBAL PROPERY P_A)
> message (STATUS "VAR_A=${VAR_A})
> 
> is that's right?


Yes, that's about right.

Michael


More information about the CMake mailing list