summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-11-13 19:25:03 (GMT)
committerKitware Robot <kwrobot@kitware.com>2018-11-13 19:25:10 (GMT)
commitdc551c2b0d8d92227a56faad80781349381869f2 (patch)
treee4d930edf14ad52ea4b5146bbd1b6b077320b4b4
parent3603b3964b308273725198cafdc2ce78a80fa862 (diff)
parentabb5945bd0b10b14cdc43966145b1a34125393cc (diff)
downloadCMake-dc551c2b0d8d92227a56faad80781349381869f2.zip
CMake-dc551c2b0d8d92227a56faad80781349381869f2.tar.gz
CMake-dc551c2b0d8d92227a56faad80781349381869f2.tar.bz2
Merge topic 'macro+function-invocation'
abb5945bd0 Help: Document that function invocation is case-insensitive 357cdee3a1 Help: Document that macro invocation is case-insensitive Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !2607
-rw-r--r--Help/command/function.rst67
-rw-r--r--Help/command/macro.rst58
2 files changed, 88 insertions, 37 deletions
diff --git a/Help/command/function.rst b/Help/command/function.rst
index 4a223b4..7b10381 100644
--- a/Help/command/function.rst
+++ b/Help/command/function.rst
@@ -9,27 +9,9 @@ Start recording a function for later invocation as a command.
<commands>
endfunction()
-Defines a function named ``<name>`` that takes arguments
-named ``<arg1>``, ...
-The ``<commands>`` in the function definition are recorded;
-they are not invoked until the function is invoked. When
-the function is invoked, the recorded ``<commands>`` are first
-modified by replacing formal parameters (``${arg1}``, ...)
-with the arguments passed, and then invoked as normal commands.
-
-In addition to referencing the formal parameters you can reference the
-``ARGC`` variable which will be set to the number of arguments passed
-into the function as well as ``ARGV0``, ``ARGV1``, ``ARGV2``, ... which
-will have the actual values of the arguments passed in.
-This facilitates creating functions with optional arguments.
-
-Furthermore, ``ARGV`` holds the list of all arguments given to the
-function and ``ARGN`` holds the list of arguments past the last expected
-argument.
-Referencing to ``ARGV#`` arguments beyond ``ARGC`` have undefined
-behavior. Checking that ``ARGC`` is greater than ``#`` is the only way
-to ensure that ``ARGV#`` was passed to the function as an extra
-argument.
+Defines a function named ``<name>`` that takes arguments named
+``<arg1>``, ... The ``<commands>`` in the function definition
+are recorded; they are not executed until the function is invoked.
Per legacy, the :command:`endfunction` command admits an optional
``<name>`` argument. If used, it must be a verbatim repeat of the
@@ -40,3 +22,46 @@ details.
See the :command:`cmake_policy()` command documentation for the behavior
of policies inside functions.
+
+Invocation
+^^^^^^^^^^
+
+The function invocation is case-insensitive. A function defined as
+
+.. code-block:: cmake
+
+ function(foo)
+ <commands>
+ endfunction()
+
+can be invoked through any of
+
+.. code-block:: cmake
+
+ foo()
+ Foo()
+ FOO()
+
+and so on. However, it is strongly recommended to stay with the
+case chosen in the function definition. Typically functions use
+all-lowercase names.
+
+Arguments
+^^^^^^^^^
+
+When the function is invoked, the recorded ``<commands>`` are first
+modified by replacing formal parameters (``${arg1}``, ...) with the
+arguments passed, and then invoked as normal commands.
+
+In addition to referencing the formal parameters you can reference the
+``ARGC`` variable which will be set to the number of arguments passed
+into the function as well as ``ARGV0``, ``ARGV1``, ``ARGV2``, ... which
+will have the actual values of the arguments passed in. This facilitates
+creating functions with optional arguments.
+
+Furthermore, ``ARGV`` holds the list of all arguments given to the
+function and ``ARGN`` holds the list of arguments past the last expected
+argument. Referencing to ``ARGV#`` arguments beyond ``ARGC`` have
+undefined behavior. Checking that ``ARGC`` is greater than ``#`` is
+the only way to ensure that ``ARGV#`` was passed to the function as an
+extra argument.
diff --git a/Help/command/macro.rst b/Help/command/macro.rst
index 287855b..e15e206 100644
--- a/Help/command/macro.rst
+++ b/Help/command/macro.rst
@@ -9,12 +9,46 @@ Start recording a macro for later invocation as a command
<commands>
endmacro()
-Defines a macro named ``<name>`` that takes arguments
-named ``<arg1>``, ...
-Commands listed after macro, but before the matching
-:command:`endmacro()`, are not invoked until the macro is invoked.
-When it is invoked, the commands recorded in the macro are first
-modified by replacing formal parameters (``${arg1}``, ...)
+Defines a macro named ``<name>`` that takes arguments named
+``<arg1>``, ... Commands listed after macro, but before the
+matching :command:`endmacro()`, are not executed until the macro
+is invoked.
+
+Per legacy, the :command:`endmacro` command admits an optional
+``<name>`` argument. If used, it must be a verbatim repeat of the
+argument of the opening ``macro`` command.
+
+See the :command:`cmake_policy()` command documentation for the behavior
+of policies inside macros.
+
+Invocation
+^^^^^^^^^^
+
+The macro invocation is case-insensitive. A macro defined as
+
+.. code-block:: cmake
+
+ macro(foo)
+ <commands>
+ endmacro()
+
+can be invoked through any of
+
+.. code-block:: cmake
+
+ foo()
+ Foo()
+ FOO()
+
+and so on. However, it is strongly recommended to stay with the
+case chosen in the macro definition. Typically macros use
+all-lowercase names.
+
+Arguments
+^^^^^^^^^
+
+When a macro is invoked, the commands recorded in the macro are
+first modified by replacing formal parameters (``${arg1}``, ...)
with the arguments passed, and then invoked as normal commands.
In addition to referencing the formal parameters you can reference the
@@ -31,16 +65,8 @@ behavior. Checking that ``${ARGC}`` is greater than ``#`` is the only
way to ensure that ``${ARGV#}`` was passed to the function as an extra
argument.
-Per legacy, the :command:`endmacro` command admits an optional
-``<name>`` argument. If used, it must be a verbatim repeat of the
-argument of the opening ``macro`` command.
-
-
-See the :command:`cmake_policy()` command documentation for the behavior
-of policies inside macros.
-
-Macro Argument Caveats
-^^^^^^^^^^^^^^^^^^^^^^
+Argument Caveats
+^^^^^^^^^^^^^^^^
Note that the parameters to a macro and values such as ``ARGN`` are
not variables in the usual CMake sense. They are string