From 8ba2a8d4a415d2288786a0d56e90b3d7693ad32e Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (l)" Date: Thu, 1 Nov 2018 11:13:03 +0100 Subject: Help: short/long variable reference in if command Explain that the short form of variable references in the if command does not apply to ENV and CACHE vars. --- Help/command/if.rst | 6 +++++- Help/manual/cmake-language.7.rst | 12 +++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Help/command/if.rst b/Help/command/if.rst index 4781f35..ea5de7f 100644 --- a/Help/command/if.rst +++ b/Help/command/if.rst @@ -231,7 +231,7 @@ which is true because ``var2`` is defined to "var1" which is not a false constant. Automatic evaluation applies in the other cases whenever the -above-documented signature accepts ````: +above-documented condition syntax accepts ````: * The left hand argument to ``MATCHES`` is first checked to see if it is a defined variable, if so the variable's value is used, otherwise the @@ -269,3 +269,7 @@ specified in a :ref:`Quoted Argument` or a :ref:`Bracket Argument`. A quoted or bracketed variable or keyword will be interpreted as a string and not dereferenced or interpreted. See policy :policy:`CMP0054`. + +There is no short form for environment or cache :ref:`Variable References`. +They can be referenced as ``$ENV{}`` or ``$CACHE{}`` +wherever the above-documented condition syntax accepts . diff --git a/Help/manual/cmake-language.7.rst b/Help/manual/cmake-language.7.rst index 1b5281a..5e5cfff 100644 --- a/Help/manual/cmake-language.7.rst +++ b/Help/manual/cmake-language.7.rst @@ -389,7 +389,7 @@ historical considerations.) Variable References ------------------- -A *variable reference* has the form ``${variable_name}`` and is +A *variable reference* has the form ``${}`` and is evaluated inside a `Quoted Argument`_ or an `Unquoted Argument`_. A variable reference is replaced by the value of the variable, or by the empty string if the variable is not set. @@ -405,12 +405,18 @@ the ``$`` is also technically permitted but is discouraged. The `Variables`_ section documents the scope of variable names and how their values are set. -An *environment variable reference* has the form ``$ENV{VAR}``. +An *environment variable reference* has the form ``$ENV{}``. See the `Environment Variables`_ section for more information. -A *cache variable reference* has the form ``$CACHE{VAR}``. +A *cache variable reference* has the form ``$CACHE{}``. See :variable:`CACHE` for more information. +The :command:`if` command has a special condition syntax that +allows for variable references in the short form ```` +instead of ``${}``. +However, environment and cache variables always need to be +referenced as ``$ENV{}`` or ``$CACHE{}``. + Comments -------- -- cgit v0.12