Commit 0ee997b1 authored by Brad King's avatar Brad King Committed by Kitware Robot
Browse files

Merge topic 'doc-if-links' into release-3.20

22140f7a

 Help: Add internal links to if() docs
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !5824
parents 98ae0051 22140f7a
Pipeline #215078 failed with stages
in 55 minutes and 33 seconds
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment