[CMake] How to declare global variables

Philip Lowman philip at yhbt.com
Sat Mar 21 20:04:48 EDT 2009


On Sat, Mar 21, 2009 at 7:32 PM, Robert Dailey <rcdailey at gmail.com> wrote:

> Currently I'm having a bit of trouble making variables defined in the
> following directory:
>
> C:\a\b\c\d\e\CMakeLists.txt
>
> Available to another script in a distant directory, located here:
>
> C:\a\b\x\y\z\CMakeLists.txt
>
> I've tried using PARENT_SCOPE, but this doesn't declare it "high"
> enough. The only possible way I've been able to make this work is by
> making it an internal cache variable. However, I do not want to
> persist the contents of the variable. Do I have any other options?


You should be able to chain PARENT_SCOPE, I think. In other words have a

set(FOO ${FOO} PARENT_SCOPE)
in all of the directories beneath the one where you actually need the
variable.

Using an internal cache variable is the only other option I can think of.

-- 
Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090321/318780b1/attachment-0001.htm>


More information about the CMake mailing list