View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015093CMakeCMakepublic2014-08-18 02:052016-06-10 14:31
Reporterabma 
Assigned ToKitware Robot 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionmoved 
PlatformOSOS Version
Product VersionCMake 2.8.12.2 
Target VersionFixed in Version 
Summary0015093: PARENT_SCOPE empties variables when recursived used
Descriptionwhen a PARENT_SCOPE'd variable is set to a value of a PARENT_SCOPE'd variable, both are empty:

set(a "a" PARENT_SCOPE)
set(b "${a}" PARENT_SCOPE)


expected result:

a = "a"
b = "a"

but in real both are empty!
Additional Informationcan be workarounded:

macro(MakeGlobalVar varname)
    set(${varname} ${ARGN} PARENT_SCOPE)
    set(${varname} ${ARGN})
endmacro()


MakeGlobalVar(a "a")
MakeGlobalVar(b "${a}")

TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0036627)
Marcel Loose (developer)
2014-08-18 04:17

This is not a bug. You set variable a in the parent scope only! So, it is not set at the current scope. Hence, you assign an empty string to variable b, also in the parent scope. No surprise to me they're both empty.

Your workaround just sets the variable twice, once at the current scope and once at the parent scope.
(0036628)
abma (reporter)
2014-08-18 05:16

from docs: "If PARENT_SCOPE is present, the variable will be set in the scope above the current scope."

i understand this, as when a variable is set "above" the current scope it will be present in current scope, too.

imo it should be noted in docs that its not valid in current scope then.
(0036629)
Ben Boeckel (developer)
2014-08-18 09:35

The previous value is "pulled" down into the current scope, including its state if it was previously undefined.
(0042609)
Kitware Robot (administrator)
2016-06-10 14:29

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2014-08-18 02:05 abma New Issue
2014-08-18 04:17 Marcel Loose Note Added: 0036627
2014-08-18 05:16 abma Note Added: 0036628
2014-08-18 09:35 Ben Boeckel Note Added: 0036629
2016-06-10 14:29 Kitware Robot Note Added: 0042609
2016-06-10 14:29 Kitware Robot Status new => resolved
2016-06-10 14:29 Kitware Robot Resolution open => moved
2016-06-10 14:29 Kitware Robot Assigned To => Kitware Robot
2016-06-10 14:31 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team