diff options
author | Joachim Wuttke (l) <j.wuttke@fz-juelich.de> | 2018-11-12 21:58:20 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-11-13 18:47:24 (GMT) |
commit | 357cdee3a133a943828d85d6441dfdee9d347751 (patch) | |
tree | 63a9c91dddc3d90034f19d69e1ab86421b52b850 /Help | |
parent | 3603b3964b308273725198cafdc2ce78a80fa862 (diff) | |
download | CMake-357cdee3a133a943828d85d6441dfdee9d347751.zip CMake-357cdee3a133a943828d85d6441dfdee9d347751.tar.gz CMake-357cdee3a133a943828d85d6441dfdee9d347751.tar.bz2 |
Help: Document that macro invocation is case-insensitive
Diffstat (limited to 'Help')
-rw-r--r-- | Help/command/macro.rst | 58 |
1 files changed, 42 insertions, 16 deletions
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 |