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

Philip Lowman philip at yhbt.com
Tue Mar 31 22:46:57 EDT 2009


On Tue, Mar 31, 2009 at 6:13 PM, James Bigler <jamesbigler at gmail.com> wrote:

> I just recently discovered another way to do this.  I was troubled that
> pushing it up to the parent scope only pushes it up one level, so if you
> want to push a variable up to the top, you must push it at each level in the
> tree.  My discovery was that using the environment variable mechanism is a
> great alternative to a global variable. ;)
>

Clever.  There is also CACHE INTERNAL which is a safer way of doing what
you're trying to do you might consider trying out.  With CACHE INTERNAL you
can't accidentally trounce environment variables that may affect execution
of your CMake scripts.  It is slightly more verbose, however.

set(foo bar CACHE INTERNAL "")

-- 
Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090331/be9f86b7/attachment.htm>


More information about the CMake mailing list