[CMake] Question about PARENT_SCOPE

Alexander Neundorf a.neundorf-work at gmx.net
Mon May 3 15:19:42 EDT 2010


On Monday 03 May 2010, Benoit Thomas wrote:
> Hello,
>
> Is it possible to do something like this (sorry if there are typos):
>
> function (bar v scope)
>      set (v 1 GRAND_PARENT_SCOPE)
> endfunction()

No :-)

> function (foo v)
>      bar (${v} PARENT_SCOPE)
> endfunction()

You could have bar() use PARENT_SCOPE to set it in a variable in bar(), which 
could then itself set it to PARENT_SCOPE.
Would that work ?

> foo (v)
> message ("${v} == 1")
>
> If it's not possible, I'll go with global variables. Currently, I do
> global variables by doing:
>
> set (v 1 CACHE INTERNAL "" FORCE)
>
> But is there a better way ?

You could also set a GLOBAL property, that's more similar to a normal variable 
than a forced CACHE variable.

Alex


More information about the CMake mailing list