On Saturday 11 December 2010, Johannes Zarl wrote:
> Hello,
>
> I noticed that when defining a function, one can access lists as
> arguments using named arguments or ARGV0..ARGVn, but not using ARGV and
> ARGN.
>
> To elaborate, assuming the function list_as_args defined as follows:
> function(list_as_arg)
>   message(STATUS "${ARGC} arguments, ARGV: ${ARGV}")
>   message(STATUS "First argument: ${ARGV0}")
>   foreach(_arg ${ARGN})
>     message(STATUS "Parsing argument ${_arg}")
>   endforeach(_arg)
> endfunction(list_as_arg)
>
> ... and called with 2 arguments:
> list_as_arg("list1a;list1b" "list2a;list2b")
>
> ...prints the following:
> -- 2 arguments, ARGV: list1a;list1b;list2a;list2b
> -- First argument: list1a;list1b
> -- Parsing argument list1a
> -- Parsing argument list1b
> -- Parsing argument list2a
> -- Parsing argument list2b
>
> So ARGV0 is not the same as the first argument of ARGV. Why? Is it that
> the ARGV and ARGN lists get flattened, but the ARGVx are assigned before
> that?
>
> How can I safely access the values of ARGN, if they might contain lists?

Do I understand correctly that you want to pass two lists of things to a 
macro/function ?
To do this, you have to separate them with keywords.

Since version 2.8.3 (or was it 2.8.2 ?) CMake comes with the module 
CMakeParseArguments.cmake which helps with evaluating such lists of 
arguments. There you can find also documentation.

Feel free to ask again if it's unclear.

Alex
_______________________________________________
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

Reply via email to