diff options
author | Joachim Wuttke (l) <j.wuttke@fz-juelich.de> | 2018-10-16 19:50:48 (GMT) |
---|---|---|
committer | Joachim Wuttke (o) <j.wuttke@fz-juelich.de> | 2018-10-23 13:12:10 (GMT) |
commit | c2efb3efcd083523a73a2a9721b7101fbfc0fe0f (patch) | |
tree | 51feae595367cd8b91ab27c34000129c9a8c38b6 /Help/command/if.rst | |
parent | 7053dd301c694bbc5e13b7e32febd34596b22d4e (diff) | |
download | CMake-c2efb3efcd083523a73a2a9721b7101fbfc0fe0f.zip CMake-c2efb3efcd083523a73a2a9721b7101fbfc0fe0f.tar.gz CMake-c2efb3efcd083523a73a2a9721b7101fbfc0fe0f.tar.bz2 |
Help: Revise docs on Scripting Commands
Revise docs for all "Scripting Commands", except four find_XXX
that use a macro suite of their own.
* Take full advantage of the improved syntax highlighting.
* Make consequential use of <..> placeholders.
* Clarify things here and there in the text.
Specific improvements to some command docs:
* "math": Correct description of novel hexadecimal capability.
* "if", "foreach", "while": Provide link to "endif" etc
* "foreach", "while": Mention "break" and "continue".
* "foreach": Simplify explanation of ``RANGE`` and ``IN`` signatures;
advise against negative arguments or reverse ranges (compare issue #18461)
* "endif", "endfunction" etc: Explain that the argument is optional and
maintained for compatibility only
Diffstat (limited to 'Help/command/if.rst')
-rw-r--r-- | Help/command/if.rst | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/Help/command/if.rst b/Help/command/if.rst index 8abe9ba..4781f35 100644 --- a/Help/command/if.rst +++ b/Help/command/if.rst @@ -6,7 +6,7 @@ Conditionally execute a group of commands. Synopsis ^^^^^^^^ -:: +.. code-block:: cmake if(<condition>) <commands> @@ -23,8 +23,11 @@ Otherwise, optional ``elseif`` blocks are processed in the same way. Finally, if no ``condition`` is true, ``commands`` in the optional ``else`` block are executed. -Per legacy, the ``else`` and ``endif`` clause may also have a ``condition`` argument, -which then must be a verbatim repeat of the argument of the opening ``if`` clause. +Per legacy, the :command:`else` and :command:`elseif` commands admit +an optional ``<condition>`` argument. +If used, it must be a verbatim +repeat of the argument of the opening +``if`` command. Condition Syntax ^^^^^^^^^^^^^^^^ @@ -202,21 +205,27 @@ The if command was written very early in CMake's history, predating the ``${}`` variable evaluation syntax, and for convenience evaluates variables named by its arguments as shown in the above signatures. Note that normal variable evaluation with ``${}`` applies before the if -command even receives the arguments. Therefore code like:: +command even receives the arguments. Therefore code like + +.. code-block:: cmake set(var1 OFF) set(var2 "var1") if(${var2}) -appears to the if command as:: +appears to the if command as + +.. code-block:: cmake - if(var1) + if(var1) and is evaluated according to the ``if(<variable>)`` case documented above. The result is ``OFF`` which is false. However, if we remove the -``${}`` from the example then the command sees:: +``${}`` from the example then the command sees + +.. code-block:: cmake - if(var2) + if(var2) which is true because ``var2`` is defined to "var1" which is not a false constant. |