[CMake] Return values from CMake functions?

Ken Martin ken.martin at kitware.com
Thu Nov 20 13:54:46 EST 2008


True, if you mismatch the typing of varname it fails. At least with this
approach it can be a fairly short variable and not something like
CXX_SHARED_LIBRARY_LINKER_FLAGS_DEBUG which begs to have typos in it :-)

> The suggestion I had was to use the ${SOMETHING(...)} syntax to invoke a
function call.  So you would have:

I don't think you need the ${} syntax. Such syntax could be used, but just
SOMETHING(...) would work as well. I remembered that the CVS version of
CMake has some parser changes already in it that allow for 

if (func())

to be parsed. It is mainly a matter of the argument expansion code being
modified to actually call func when it sees it followed by a pair of parens.
That and a bunch of changes to the signature of commands to allow for return
values/debugging info/etc. That is the bigger task. I'm assuming it would be
zero or more return values like lua, no reason to limit it to just zero or
one like C. 

Ken


Ken Martin PhD
Kitware Inc.
28 Corporate Drive
Clifton Park NY 12065
ken.martin at kitware.com
518 371 3971 (w/f)





More information about the CMake mailing list