From 3a9695557dc68e6520159ec69e21483a1311b420 Mon Sep 17 00:00:00 2001 From: Craig Scott Date: Sun, 28 Nov 2021 20:52:42 +1100 Subject: Help: Explicitly state that if(ENV{some_var}) is always false --- Help/command/if.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Help/command/if.rst b/Help/command/if.rst index 6ff8852..b4b4897 100644 --- a/Help/command/if.rst +++ b/Help/command/if.rst @@ -61,7 +61,9 @@ Basic Expressions ``if()`` 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. 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. Logic Operators """"""""""""""" -- cgit v0.12 From 294581a4436714367093052151b501d64f6c47f3 Mon Sep 17 00:00:00 2001 From: Craig Scott Date: Wed, 1 Dec 2021 18:59:23 +1100 Subject: Help: Be more explicit about the behavior of if() --- Help/command/if.rst | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Help/command/if.rst b/Help/command/if.rst index b4b4897..5dba13e 100644 --- a/Help/command/if.rst +++ b/Help/command/if.rst @@ -56,15 +56,24 @@ 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()`` +``if()`` True if given a variable that is defined to a value that is not a false - constant. False otherwise. Note that 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()`` + 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 """"""""""""""" -- cgit v0.12