mirror of
https://github.com/Kitware/CMake.git
synced 2026-03-09 18:09:02 -05:00
Merge branch 'help_parse_arguments' into release-3.10
Merge-request: !1397
This commit is contained in:
@@ -43,15 +43,18 @@ macro which can be followed by more than one value, like e.g. the
|
||||
``<multi_value_keywords>``. A warning will be emitted if uniqueness is
|
||||
violated.
|
||||
|
||||
When done, ``cmake_parse_arguments`` will have defined for each of the
|
||||
When done, ``cmake_parse_arguments`` will consider for each of the
|
||||
keywords listed in ``<options>``, ``<one_value_keywords>`` and
|
||||
``<multi_value_keywords>`` a variable composed of the given ``<prefix>``
|
||||
followed by ``"_"`` and the name of the respective keyword. These
|
||||
variables will then hold the respective value from the argument list.
|
||||
For the ``<options>`` keywords this will be ``TRUE`` or ``FALSE``.
|
||||
variables will then hold the respective value from the argument list
|
||||
or be undefined if the associated option could not be found.
|
||||
For the ``<options>`` keywords, these will always be defined,
|
||||
to ``TRUE`` or ``FALSE``, whether the option is in the argument list or not.
|
||||
|
||||
All remaining arguments are collected in a variable
|
||||
``<prefix>_UNPARSED_ARGUMENTS``, this can be checked afterwards to see
|
||||
``<prefix>_UNPARSED_ARGUMENTS`` that will be undefined if all argument
|
||||
where recognized. This can be checked afterwards to see
|
||||
whether your macro was called with unrecognized parameters.
|
||||
|
||||
As an example here a ``my_install()`` macro, which takes similar arguments
|
||||
@@ -74,16 +77,16 @@ Assume ``my_install()`` has been called like this:
|
||||
|
||||
my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub)
|
||||
|
||||
After the ``cmake_parse_arguments`` call the macro will have set the
|
||||
following variables::
|
||||
After the ``cmake_parse_arguments`` call the macro will have set or undefined
|
||||
the following variables::
|
||||
|
||||
MY_INSTALL_OPTIONAL = TRUE
|
||||
MY_INSTALL_FAST = FALSE (was not used in call to my_install)
|
||||
MY_INSTALL_FAST = FALSE # was not used in call to my_install
|
||||
MY_INSTALL_DESTINATION = "bin"
|
||||
MY_INSTALL_RENAME = "" (was not used)
|
||||
MY_INSTALL_RENAME <UNDEFINED> # was not used
|
||||
MY_INSTALL_TARGETS = "foo;bar"
|
||||
MY_INSTALL_CONFIGURATIONS = "" (was not used)
|
||||
MY_INSTALL_UNPARSED_ARGUMENTS = "blub" (nothing expected after "OPTIONAL")
|
||||
MY_INSTALL_CONFIGURATIONS <UNDEFINED> # was not used
|
||||
MY_INSTALL_UNPARSED_ARGUMENTS = "blub" # nothing expected after "OPTIONAL"
|
||||
|
||||
You can then continue and process these variables.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user