[CMake] Parameters of functions
Rolf Eike Beer
eike at sf-mail.de
Thu May 12 02:27:52 EDT 2011
> This is funny:
> FUNCTION(build var)
> MESSAGE(STATUS "var: " ${${var}})
> ENDFUNCTION(build)
>
> SET(var red blue yellow green)
> build(var)
>
> Output:
> -- var: var
>
> SET(varX red blue yellow green)
> build(varX)
> Output:
> -- var: redblueyellowgreen
No, it must be that way. Inside build() var is defined as the variable
that is defined in the interface. build() has no way to see the variable
outside it because it can only find the inner name. It could reference
it's value if you had passed the value or it could reference the variable
by name if it would not be hidden by your interface variable.
int a = 2;
int build(int a)
{
return a;
}
int b = build(42);
b will be 42.
Eike
More information about the CMake
mailing list