summaryrefslogtreecommitdiffstats
path: root/Help/command/if.rst
diff options
context:
space:
mode:
authorMichael Hirsch, Ph.D <michael@scivision.dev>2021-01-26 02:14:43 (GMT)
committerBrad King <brad.king@kitware.com>2021-02-18 15:20:34 (GMT)
commit22140f7af33900dadb1cf946a97f598f2f5a3415 (patch)
treeeb1037e2e5ca0599e6fe54208289bb2128b02dbb /Help/command/if.rst
parent50fc9d5b45a7dcbb11152ea77b2d47c66e277265 (diff)
downloadCMake-22140f7af33900dadb1cf946a97f598f2f5a3415.zip
CMake-22140f7af33900dadb1cf946a97f598f2f5a3415.tar.gz
CMake-22140f7af33900dadb1cf946a97f598f2f5a3415.tar.bz2
Help: Add internal links to if() docs
Diffstat (limited to 'Help/command/if.rst')
-rw-r--r--Help/command/if.rst58
1 files changed, 51 insertions, 7 deletions
diff --git a/Help/command/if.rst b/Help/command/if.rst
index 5dabe00..f327ca9 100644
--- a/Help/command/if.rst
+++ b/Help/command/if.rst
@@ -39,13 +39,13 @@ the ``if``, ``elseif`` and :command:`while` clauses.
Compound conditions are evaluated in the following order of precedence:
Innermost parentheses are evaluated first. Next come unary tests such
-as ``EXISTS``, ``COMMAND``, and ``DEFINED``. Then binary tests such as
-``EQUAL``, ``LESS``, ``LESS_EQUAL``, ``GREATER``, ``GREATER_EQUAL``,
-``STREQUAL``, ``STRLESS``, ``STRLESS_EQUAL``, ``STRGREATER``,
-``STRGREATER_EQUAL``, ``VERSION_EQUAL``, ``VERSION_LESS``,
-``VERSION_LESS_EQUAL``, ``VERSION_GREATER``, ``VERSION_GREATER_EQUAL``,
-and ``MATCHES``. Then the boolean operators in the order ``NOT``, ``AND``,
-and finally ``OR``.
+as `EXISTS`_, `COMMAND`_, and `DEFINED`_. Then binary tests such as
+`EQUAL`_, `LESS`_, `LESS_EQUAL`_, `GREATER`_, `GREATER_EQUAL`_,
+`STREQUAL`_, `STRLESS`_, `STRLESS_EQUAL`_, `STRGREATER`_,
+`STRGREATER_EQUAL`_, `VERSION_EQUAL`_, `VERSION_LESS`_,
+`VERSION_LESS_EQUAL`_, `VERSION_GREATER`_, `VERSION_GREATER_EQUAL`_,
+and `MATCHES`_. Then the boolean operators in the order `NOT`_, `AND`_,
+and finally `OR`_.
Basic Expressions
"""""""""""""""""
@@ -66,12 +66,18 @@ Basic Expressions
Logic Operators
"""""""""""""""
+.. _NOT:
+
``if(NOT <condition>)``
True if the condition is not true.
+.. _AND:
+
``if(<cond1> AND <cond2>)``
True if both conditions would be considered true individually.
+.. _OR:
+
``if(<cond1> OR <cond2>)``
True if either condition would be considered true individually.
@@ -84,6 +90,8 @@ Logic Operators
Existence Checks
""""""""""""""""
+.. _COMMAND:
+
``if(COMMAND command-name)``
True if the given name is a command, macro or function that can be
invoked.
@@ -102,6 +110,8 @@ Existence Checks
True if the given name is an existing test name created by the
:command:`add_test` command.
+.. _DEFINED:
+
``if(DEFINED <name>|CACHE{<name>}|ENV{<name>})``
True if a variable, cache variable or environment variable
with given ``<name>`` is defined. The value of the variable
@@ -117,6 +127,8 @@ Existence Checks
File Operations
"""""""""""""""
+.. _EXISTS:
+
``if(EXISTS path-to-file-or-directory)``
True if the named file or directory exists. Behavior is well-defined
only for explicit full paths (a leading ``~/`` is not expanded as
@@ -146,6 +158,8 @@ File Operations
Comparisons
"""""""""""
+.. _MATCHES:
+
``if(<variable|string> MATCHES regex)``
True if the given string or variable's value matches the given regular
condition. See :ref:`Regex Specification` for regex format.
@@ -153,45 +167,65 @@ Comparisons
.. versionadded:: 3.9
``()`` groups are captured in :variable:`CMAKE_MATCH_<n>` variables.
+.. _LESS:
+
``if(<variable|string> LESS <variable|string>)``
True if the given string or variable's value is a valid number and less
than that on the right.
+.. _GREATER:
+
``if(<variable|string> GREATER <variable|string>)``
True if the given string or variable's value is a valid number and greater
than that on the right.
+.. _EQUAL:
+
``if(<variable|string> EQUAL <variable|string>)``
True if the given string or variable's value is a valid number and equal
to that on the right.
+.. _LESS_EQUAL:
+
``if(<variable|string> LESS_EQUAL <variable|string>)``
.. versionadded:: 3.7
True if the given string or variable's value is a valid number and less
than or equal to that on the right.
+.. _GREATER_EQUAL:
+
``if(<variable|string> GREATER_EQUAL <variable|string>)``
.. versionadded:: 3.7
True if the given string or variable's value is a valid number and greater
than or equal to that on the right.
+.. _STRLESS:
+
``if(<variable|string> STRLESS <variable|string>)``
True if the given string or variable's value is lexicographically less
than the string or variable on the right.
+.. _STRGREATER:
+
``if(<variable|string> STRGREATER <variable|string>)``
True if the given string or variable's value is lexicographically greater
than the string or variable on the right.
+.. _STREQUAL:
+
``if(<variable|string> STREQUAL <variable|string>)``
True if the given string or variable's value is lexicographically equal
to the string or variable on the right.
+.. _STRLESS_EQUAL:
+
``if(<variable|string> STRLESS_EQUAL <variable|string>)``
.. versionadded:: 3.7
True if the given string or variable's value is lexicographically less
than or equal to the string or variable on the right.
+.. _STRGREATER_EQUAL:
+
``if(<variable|string> STRGREATER_EQUAL <variable|string>)``
.. versionadded:: 3.7
True if the given string or variable's value is lexicographically greater
@@ -200,24 +234,32 @@ Comparisons
Version Comparisons
"""""""""""""""""""
+.. _VERSION_LESS:
+
``if(<variable|string> VERSION_LESS <variable|string>)``
Component-wise integer version number comparison (version format is
``major[.minor[.patch[.tweak]]]``, omitted components are treated as zero).
Any non-integer version component or non-integer trailing part of a version
component effectively truncates the string at that point.
+.. _VERSION_GREATER:
+
``if(<variable|string> VERSION_GREATER <variable|string>)``
Component-wise integer version number comparison (version format is
``major[.minor[.patch[.tweak]]]``, omitted components are treated as zero).
Any non-integer version component or non-integer trailing part of a version
component effectively truncates the string at that point.
+.. _VERSION_EQUAL:
+
``if(<variable|string> VERSION_EQUAL <variable|string>)``
Component-wise integer version number comparison (version format is
``major[.minor[.patch[.tweak]]]``, omitted components are treated as zero).
Any non-integer version component or non-integer trailing part of a version
component effectively truncates the string at that point.
+.. _VERSION_LESS_EQUAL:
+
``if(<variable|string> VERSION_LESS_EQUAL <variable|string>)``
.. versionadded:: 3.7
Component-wise integer version number comparison (version format is
@@ -225,6 +267,8 @@ Version Comparisons
Any non-integer version component or non-integer trailing part of a version
component effectively truncates the string at that point.
+.. _VERSION_GREATER_EQUAL:
+
``if(<variable|string> VERSION_GREATER_EQUAL <variable|string>)``
.. versionadded:: 3.7
Component-wise integer version number comparison (version format is