On Tuesday 05 November 2013, Daniele E. Domenichelli wrote:
> Hello all,
>
> Current implementation of cmake_parse_arguments skips empty arguments.
>
> For example:
>
> cmake_parse_arguments("OPTION" "SINGLE" "MULTI" ${ARGN})
>
> with ARGN that is set using something like:
>
> <args> SINGLE "" <more args> # (<args>;SINGLE;;<more args>)
> <args> SINGLE "" # (<args>;SINGLE;)
>
> it will fail in 3 different ways:
>
> 1) because the "foreach" skips empty arguments
> 2) because list(APPEND <list> ${currentArg}) will fail to append an
> empty element to the list if currentArg is an empty string.
> 3) because empty arguments are not passed to cmake_parse_arguments
> if not quoted, i.e. if ARGN="a;;b"
> * ${ARGN} will pass the arguments "a", "b"
> * "${ARGN}" will pass the arguments "a", "", "b"
Not sure about the third point. It could be done intentionally that way in
order to ignore empty strings.
> I wrote a small patch to fix this, you can find it in the
> CMakeParseArguments_EmptyArgs topic. This patch fixes the first
> behaviour using foreach(IN LISTS) version, the second by enclosing
> currentArg in quotes where required, and finally fixes the documentation
> in order to suggest to use quoted "${ARGN}" in order not to miss the
> empty arguments at the end of the list.
>
> I don't know if this is to be considered a change of behaviour though,
> but I'd rather consider it a bug, and I would like to see it fixed in
> the next bugfix release... what do you think?
cmake_parse_arguments() is used in quite a few places in the meantime, so I
don't really feel good about changing its behaviour in general.
Maybe an option for the macro what it should do with empty values ?
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://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers