cmake_parse_arguments: Add PARSE_ARGN mode

Introduce a mode similar to `PARSE_ARGV` that avoids needing
to specify the number of normal function arguments.

Closes: #25376
This commit is contained in:
Arha Gatram
2026-06-01 13:41:05 -07:00
committed by Brad King
parent 4d945a6491
commit 97c36916d9
18 changed files with 151 additions and 11 deletions

View File

@@ -11,6 +11,9 @@ Parse function or macro arguments.
cmake_parse_arguments(PARSE_ARGV <N> <prefix> <options>
<one_value_keywords> <multi_value_keywords>)
cmake_parse_arguments(PARSE_ARGN <prefix> <options>
<one_value_keywords> <multi_value_keywords>)
.. versionadded:: 3.5
This command is implemented natively. Previously, it has been defined in the
module :module:`CMakeParseArguments`.
@@ -30,6 +33,12 @@ This may be used in either a :command:`macro` or a :command:`function`.
the ``<N>``-th argument, where ``<N>`` is an unsigned integer.
This allows for the values to have special characters like ``;`` in them.
.. versionadded:: 4.4
The ``PARSE_ARGN`` signature is only for use in a :command:`function`
body. This starts parsing after the last named argument of the calling
function and works exactly like ``PARSE_ARGV`` with ``<N>`` being the number
of parameters in the function definition.
The ``<options>`` argument contains all options for the respective function
or macro. These are keywords that have no value following them, like the
``OPTIONAL`` keyword of the :command:`install` command.