[CMake] How to pass a write-parameter to a "MACRO"?
Brandon Van Every
bvanevery at gmail.com
Sat Dec 1 16:23:04 EST 2007
On Dec 1, 2007 3:13 PM, Steven Van Ingelgem <steven at vaningelgem.be> wrote:
> What I want to do is to pass a parameter to a macro which will be
> "SET" at the end of the macro.
> In fact I want it to behave a little as a "function" with it's own
> variable scope.
>
> Does anyone know how I could do that?
Uuuh, do you mean
macro(myfunction myparam)
# blah blah blah
set(${myparam} whatever)
endmacro(myfunction)
${myparam} evaluates to the global variable that you fed to the macro.
There is no local scope in current CMake. We've had extensive
argument about the need for scope recently. One approach is to
improve the CMake script language. There are some proposals in the
recent thread "lexical scoping", and some people at Kitware may be
willing to act on one or more of them sometime soon. Another approach
is to embed Lua into CMake. Ken has shown proof-of-concept that it's
doable, but there's no consensus that it's desirable.
Do you feel the documentation of macro() is adequate to explain the
formal argument processing, or is more needed?
Cheers,
Brandon Van Every
More information about the CMake
mailing list