[cmake-developers] CMakeParseArguments: Do not skip empty arguments
Daniele E. Domenichelli
daniele.domenichelli at gmail.com
Fri Nov 8 11:54:12 EST 2013
Hello,
I updated the CMakeParseArguments_EmptyArgs topic, the new behaviour is
now decided as follows:
* If CMAKE_MINIMUM_REQUIRED_VERSION < 2.8.13, the default behaviour is
to skip empty arguments, otherwise the default behaviour is to keep
them.
* Using the CMAKE_PARSE_ARGUMENTS_DEFAULT_SKIP_EMPTY directory
property the user can explicitly set the default behaviour for a
folder and its subfolders.
* Using CMAKE_PARSE_ARGUMENTS_(SKIP|KEEP)_EMPTY or as the first
argument of the call after the mandatory ones, the user can specify
whether to keep or to skip the empty arguments, regardless of the
default behaviour for that cmake_parse_arguments() call.
Therefore the new syntax is:
cmake_parse_arguments(
<prefix>
<options>
<one_value_keywords>
<multi_value_keywords>
[CMAKE_PARSE_ARGUMENTS_(SKIP|KEEP)_EMPTY]
args...
)
Does it look better now?
Unfortunately there still a big problem, that is probably in the c++
source code, because "set(<var> "<value>" PARENT_SCOPE)" still fails if
<value> is empty. This is a small example that shows the problem:
---
function(_foo)
set(FOO "" PARENT_SCOPE)
endfunction()
foo(FOO "foo")
_foo()
if(DEFINED FOO)
message("FOO DEFINED")
else()
message("FOO NOT DEFINED")
endif()
set(BAR "")
if(DEFINED BAR)
message("BAR DEFINED")
else()
message("BAR NOT DEFINED")
endif()
---
The output of this is:
FOO NOT DEFINED
BAR DEFINED
So it looks like that "set(FOO "" PARENT_SCOPE)" instead of setting an
empty FOO value, unsets it in the parent scope, and the behaviour is
definitely different from set for the current scope.
This looks like a bug to me... How should I handle this?
Cheers,
Daniele
More information about the cmake-developers
mailing list