AW: [CMake] Re: How to update a variable inside a subfolder?

Gerhard Grimm ggrimm at detec.de
Tue Jan 30 13:09:51 EST 2007


Hi kitts!

This property-based approach works fine for me:

------

set(MyVar "initial value")

add_subdirectory("MyDir")

get_directory_property(MyVar DIRECTORY "MyDir"
                       DEFINITION MyVar)

------

While processing CMakeLists.txt in subdirectory "MyDir", the variable
MyVar will initially be "initial value", but might be modified.
After returning to the parent directory, the final value of MyVar within
MyDir is retrieved, updating the parent's MyVar variable.
Of course, this solution can also be applied recursively...

Best regards,

Gerhard


More information about the CMake mailing list