[CMake] Variables propagating upwards

Brad King brad.king at kitware.com
Sat Sep 23 10:09:14 EDT 2006


Lachlan Gunn wrote:
> Hi,
> I have been working on a project that makes use of  CMake, and a
> problem has come up during the course of development.
> 
> When I set a variable in a lower-level CMakeLists.txt file, it does
> not propagate upwards into the parent CMakeLists.txt file.  Example:
> 
> src/CMakeLists.txt
> -------------------------
> SET(VAR foo)
> ADD_SUBDIRECTORY(foo)
> MESSAGE("=${VAR}=")
> 
> src/foo/CMakeLists.txt
> -------------------------------
> SET(VAR bar)
> -------------------------------
> 
> The above will give an output of "=foo=", with an expected output of
> "=bar=".  Could anyone point me to the relevant documentation please?

Variables do not move upwards in order to isolate projects and 
sub-projects.  You can get values from subdirectories using the 
GET_DIRECTORY_PROPERTY command.

-Brad


More information about the CMake mailing list