[CMake] How to pass values up to parent CMakeLists.txt

Tyler Roscoe tyler at cryptio.net
Tue Mar 31 16:50:17 EDT 2009


On Tue, Mar 31, 2009 at 04:47:23PM -0400, Lezz Giles wrote:
> What I want to do is pass values up from src/CMakeLists.txt and tst/CMakeLists.txt that can be used in the custom_command.  A normal variable doesn't work - the value is scoped to the current CMakeLists.txt file.  I can define the values in the project CMakeLists.txt, but then that separates them from where they really should be, i.e. src|tst/CMakeLists.txt.

Look at the PARENT_SCOPE argument to set():

If PARENT_SCOPE is present, the variable will be set in the scope above
the current scope. Each new directory or function creates a new scope.
This command will set the value of a variable into the parent directory
or calling function (whichever is applicable to the case at hand) If
VALUE is not specified then the variable is removed from the parent
scope.


tyler


More information about the CMake mailing list