[CMake] Question about PARENT_SCOPE

Benoit Thomas benoit.thomas at gameloft.com
Mon May 3 15:41:23 EDT 2010


On 2010-05-03 15:00, Clinton Stimpson wrote:
> On Monday 03 May 2010 12:42:58 pm 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()
>>
>> function (foo v)
>>       bar (${v} PARENT_SCOPE)
>> endfunction()
>>
>> 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 ?
>>      
>
> Did you mean like this?
>
> function (bar v)
>    set (${v} 1 PARENT_SCOPE)
> endfunction()
>
> function (foo v)
>    bar(v1)
>    set(${v} ${v1} PARENT_SCOPE)
> endfunction()
>
> foo (v)
> message ("${v} == 1")
>
> Clint
>    
Thanks for the answer; I didn't really though of it that way.

--
Ben.


More information about the CMake mailing list