[CMake] Problem accessing variables and libraries in root, when they have been set in a subdirectory

Tyler Roscoe tyler at cryptio.net
Sat May 23 13:53:09 EDT 2009


On Sat, May 23, 2009 at 04:12:46PM +0200, Eugen Funk wrote:
> *root/src/core:*
> FILE(GLOB srcs_cpp ./*.cpp)
> ADD_LIBRARY(corelib ${srcs_cpp})

It is recommended that you use an explicit list of source files rather
than using file(GLOB). Consult the docs for more details.

> I ran some tests on variables and found out that:
> if in *root/src/core* I use
> SET(VAR1 "somevalue")
> then I cannot access it in root or any other structures using
> MESSAGE(STATUS "VAR1=${VAR})

Each project defined in a CMakeLists has its own scope. Investigate the
PARENT_SCOPE parameter to set() or look at using
[set|get]_target_properties to pass the values between your projects.

tyler


More information about the CMake mailing list