[cmake-developers] Review request: set_emptyvar_PARENT_SCOPE
Matthew Woehlke
matthew.woehlke at kitware.com
Mon Nov 11 18:32:18 EST 2013
On 2013-11-11 17:33, Daniele E. Domenichelli wrote:
> On 11/11/13 17:52, Matthew Woehlke wrote:
>> On 2013-11-11 05:13, Daniele E. Domenichelli wrote:
>> WCTS, how does one now unset a variable in parent scope?
>>
>> I recall some time back there was talk of adding PARENT_SCOPE to
>> unset(). If set() can no longer be used for this purpose, maybe unset()
>> should gain a PARENT_SCOPE option first / at the same time?
>
> According to
>
> http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=261c2482
>
> it seems that unset() already supports that...
Okay, thanks. (I was looking at the help of a slightly older version and
not recalling it did indeed get added.)
> So, to summarize:
>
> set(VAR PARENT_SCOPE)
> unset(VAR PARENT_SCOPE)
>
> will unset the variable in the parent scope
>
> set(VAR "" PARENT_SCOPE)
>
> will instead set an empty variable in the parent scope.
>
>
> This also means that one can use
>
> set(VAR ${VAR} PARENT_SCOPE)
>
> to set VAR in the parent scope if the variable in the current scope is
> defined and is not empty, otherwise to unset it, or
>
> set(VAR "${VAR}" PARENT_SCOPE)
>
> to always set a variable VAR in the parent scope, using the value of the
> variable in current scope, if it is defined, or an empty string if VAR
> is not defined in current scope. This is actually the same exact
> behaviour of set(VAR ${FOO}) and set(VAR "${FOO}") for the current scope
>
> Does this seem good enough?
Seems reasonable to me. Thanks.
--
Matthew
More information about the cmake-developers
mailing list