[CMake] Re: function and raise_scope commands (+ unset bug)

Ken Martin ken.martin at kitware.com
Mon Feb 18 10:17:33 EST 2008


> Would
> RAISE_SCOPE(var1 var2 ... varN)
> be better ?
> Why was the syntax changed from that to
> RAISE_SCOPE(varname value) ?
> (which was basically a set() and that's why converted to
> set(... PARENT_SCOPE)  )

The old syntax of raise scope often required that you first set the value of
the variable locally then raise it. This was prone to cause variable
collision. For example...

function (foo var)
  set ("${var}" "wasabi"}
  raise_scope("${var}")
endfunction(foo)

foo(var)
message ("var should be set to wasabi but is set to: ${var}")

results in var being undefined when it should be set to wasabi. Using the
new syntax...

function (foo var)
  set ("${var}" "wasabi" PARENT_SCOPE}
endfunction(foo)

foo(var)
message ("var should be set to wasabi but is set to: ${var}")

produces the correct result.

Ken




More information about the CMake mailing list