[CMake] Function and list
Michael Wild
themiwi at gmail.com
Wed Mar 2 10:04:40 EST 2011
On 03/02/2011 03:52 PM, Anton Sibilev wrote:
> Hello! I have a function like
>
> FUNCTION (MY_FUNC list)
> MESSAGE ("..${list}")
> ENDFUNCTION ()
>
> And I call it like:
> SET (list 11 22 33 44 55)
> MY_FUNC (list)
>
> and output is:
> ..11
>
> How I can work with lists or unknown number of arguments in functions?
Try typing "cmake --help-command function" on the command line.
Especially look at ARGN...
BTW, what you are doing is passing in the *name* of a list. And the
output isn't "..11", but "..list". You could fix it by changing the
function to read
FUNCTION (MY_FUNC list)
MESSAGE ("..${${list}}")
ENDFUNCTION ()
And "list" or "LIST" (or any other capitalization) is a built-in
function, so you shouldn't use it as a variable name.
Michael
More information about the CMake
mailing list