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
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake