[CMake] function and raise_scope commands

Filipe Sousa natros at gmail.com
Fri Dec 7 17:42:57 EST 2007


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}")

terminate called after throwing an instance of 'std::logic_error'
  what():  basic_string::_S_construct NULL not valid
Aborted

If I change ${x} to x the result y is not defined:
unction(foo x)
  set(x 1)
  raise_scope(x)
endfunction()

foo(y)
message(STATUS "y=${y}")
-- y=
-- Configuring done
-- Generating done

And the next example works:
function(foo z)
  set(x 1)
  raise_scope(x)
endfunction()

foo(f)
message(STATUS "x=${x}")
-- x=1
-- Configuring done
-- Generating done

If I understand your example, the raise_scope is the way to return
values from functions.

Thanks
--
Filipe Sousa

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
Url : http://public.kitware.com/pipermail/cmake/attachments/20071207/22bfdd8e/signature.pgp


More information about the CMake mailing list