summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-12-01 14:37:20 (GMT)
committerKitware Robot <kwrobot@kitware.com>2021-12-01 14:37:40 (GMT)
commit55c4f54e48638528cad6803b1e09bda62aaa0a0a (patch)
tree8bd7efb595f746768f5c1d78d0b5cc8868c019b6
parentcab4551889f09e433e729835c3e09dc20f102d06 (diff)
parent294581a4436714367093052151b501d64f6c47f3 (diff)
downloadCMake-55c4f54e48638528cad6803b1e09bda62aaa0a0a.zip
CMake-55c4f54e48638528cad6803b1e09bda62aaa0a0a.tar.gz
CMake-55c4f54e48638528cad6803b1e09bda62aaa0a0a.tar.bz2
Merge topic 'doc-if-basic-expressions' into release-3.22
294581a443 Help: Be more explicit about the behavior of if(<string>) 3a9695557d Help: Explicitly state that if(ENV{some_var}) is always false Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !6768
-rw-r--r--Help/command/if.rst19
1 files changed, 15 insertions, 4 deletions
diff --git a/Help/command/if.rst b/Help/command/if.rst
index 6ff8852..5dba13e 100644
--- a/Help/command/if.rst
+++ b/Help/command/if.rst
@@ -56,12 +56,23 @@ Basic Expressions
``NO``, ``FALSE``, ``N``, ``IGNORE``, ``NOTFOUND``, the empty string,
or ends in the suffix ``-NOTFOUND``. Named boolean constants are
case-insensitive. If the argument is not one of these specific
- constants, it is treated as a variable or string and the following
- signature is used.
+ constants, it is treated as a variable or string (see `Variable Expansion`_
+ further below) and one of the following two forms applies.
-``if(<variable|string>)``
+``if(<variable>)``
True if given a variable that is defined to a value that is not a false
- constant. False otherwise. (Note macro arguments are not variables.)
+ constant. False otherwise, including if the variable is undefined.
+ Note that macro arguments are not variables.
+ Environment variables also cannot be tested this way, e.g.
+ ``if(ENV{some_var})`` will always evaluate to false.
+
+``if(<string>)``
+ A quoted string always evaluates to false unless:
+
+ * The string's value is one of the true constants, or
+ * Policy :policy:`CMP0054` is not set to ``NEW`` and the string's value
+ happens to be a variable name that is affected by :policy:`CMP0054`'s
+ behavior.
Logic Operators
"""""""""""""""