[CMake] function and raise_scope commands
Miguel A. Figueroa-Villanueva
miguelf at ieee.org
Fri Dec 7 18:42:03 EST 2007
On Dec 7, 2007 6:42 PM, Filipe Sousa wrote:
> Ken Martin wrote:
> > I checked into CVS two new commands; function and raise_scope (well three
> > commands if you count endfunction)
>
> I'm having troubles with functions, the next example gives me an exception
>
> function(foo x)
> set(x 1)
> raise_scope(${x})
> endfunction()
>
> foo(y)
> message(STATUS "y=${y}")
Try the following:
function(foo x)
set(${x} 1) # changed here
raise_scope(${x})
endfunction()
foo(y)
message(STATUS "y=${y}")
I have this working. What gives me problems is calling foo(x), since x
is the same name as the function argument. So unless this is fixed, I
suggest you use names for function arguments that are not likely to be
used themselves as the name of the variable to be passed to the
function. That is, I would do: function(foo _x). Or something like
that.
Hope this helps.
--Miguel
More information about the CMake
mailing list