[cmake-developers] CMakeParseArguments: Do not skip empty arguments
Brad King
brad.king at kitware.com
Wed Dec 4 08:20:51 EST 2013
On 12/04/2013 04:57 AM, Daniele E. Domenichelli wrote:
>> Stepping back for a moment: This macro is now a huge amount of
>> CMake code to do keyword argument processing for each invocation
>> of the calling macro or function. Accumulation of such uses adds
>> overhead to CMake language processing. It was previously proposed
>> in this thread to convert the implementation of the command to be
>> in C++. IMO this is still worth investigating, if only as a follow
>> up to this topic.
>
> +1, since this is a very useful feature.
Actually after thinking about this over night I realized that converting
to a C++ implementation is the best way to fix the empty argument handling
too. The use of "CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 3.0.0" and
the directory-scoped CMAKE_PARSE_ARGUMENTS_DEFAULT_SKIP_EMPTY setting for
compatibility are an approximation of a CMake Policy. We should just use
a policy for it instead so that proper warnings can be given (when empty
arguments are passed) about the change in behavior. While it is possible
to implement a policy in CMake-language code it is much easier in C++ code.
Converting to C++ will have other benefits already discussed.
> But still it the module should be there for compatibility for
> compatibility with scripts already using that, and the old
> implementation should be there too in order to be able to backport the
> module with older cmake versions...
The module can be provided as an empty file except for documentation.
Any project including it will expect to be able to call cmake_parse_arguments
afterwards, which they will be able to since it will be a builtin command.
With the policy handling compatibility there is no need to keep the old
macro implementation. If a project has its own copy of the module it
will simply replace the builtin command and get the original behavior.
-Brad
More information about the cmake-developers
mailing list