Parcourir la source

Merge topic 'doc-if-links'

22140f7af3 Help: Add internal links to if() docs

Acked-by: Kitware Robot <[email protected]>
Merge-request: !5824
Brad King il y a 4 ans
Parent
commit
bc94ff7945
1 fichiers modifiés avec 51 ajouts et 7 suppressions
  1. 51 7
      Help/command/if.rst

+ 51 - 7
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:
 Compound conditions are evaluated in the following order of precedence:
 Innermost parentheses are evaluated first. Next come unary tests such
 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
 Basic Expressions
 """""""""""""""""
 """""""""""""""""
@@ -66,12 +66,18 @@ Basic Expressions
 Logic Operators
 Logic Operators
 """""""""""""""
 """""""""""""""
 
 
+.. _NOT:
+
 ``if(NOT <condition>)``
 ``if(NOT <condition>)``
  True if the condition is not true.
  True if the condition is not true.
 
 
+.. _AND:
+
 ``if(<cond1> AND <cond2>)``
 ``if(<cond1> AND <cond2>)``
  True if both conditions would be considered true individually.
  True if both conditions would be considered true individually.
 
 
+.. _OR:
+
 ``if(<cond1> OR <cond2>)``
 ``if(<cond1> OR <cond2>)``
  True if either condition would be considered true individually.
  True if either condition would be considered true individually.
 
 
@@ -84,6 +90,8 @@ Logic Operators
 Existence Checks
 Existence Checks
 """"""""""""""""
 """"""""""""""""
 
 
+.. _COMMAND:
+
 ``if(COMMAND command-name)``
 ``if(COMMAND command-name)``
  True if the given name is a command, macro or function that can be
  True if the given name is a command, macro or function that can be
  invoked.
  invoked.
@@ -102,6 +110,8 @@ Existence Checks
   True if the given name is an existing test name created by the
   True if the given name is an existing test name created by the
   :command:`add_test` command.
   :command:`add_test` command.
 
 
+.. _DEFINED:
+
 ``if(DEFINED <name>|CACHE{<name>}|ENV{<name>})``
 ``if(DEFINED <name>|CACHE{<name>}|ENV{<name>})``
  True if a variable, cache variable or environment variable
  True if a variable, cache variable or environment variable
  with given ``<name>`` is defined. The value of the variable
  with given ``<name>`` is defined. The value of the variable
@@ -117,6 +127,8 @@ Existence Checks
 File Operations
 File Operations
 """""""""""""""
 """""""""""""""
 
 
+.. _EXISTS:
+
 ``if(EXISTS path-to-file-or-directory)``
 ``if(EXISTS path-to-file-or-directory)``
  True if the named file or directory exists.  Behavior is well-defined
  True if the named file or directory exists.  Behavior is well-defined
  only for explicit full paths (a leading ``~/`` is not expanded as
  only for explicit full paths (a leading ``~/`` is not expanded as
@@ -146,6 +158,8 @@ File Operations
 Comparisons
 Comparisons
 """""""""""
 """""""""""
 
 
+.. _MATCHES:
+
 ``if(<variable|string> MATCHES regex)``
 ``if(<variable|string> MATCHES regex)``
  True if the given string or variable's value matches the given regular
  True if the given string or variable's value matches the given regular
  condition.  See :ref:`Regex Specification` for regex format.
  condition.  See :ref:`Regex Specification` for regex format.
@@ -153,45 +167,65 @@ Comparisons
  .. versionadded:: 3.9
  .. versionadded:: 3.9
   ``()`` groups are captured in :variable:`CMAKE_MATCH_<n>` variables.
   ``()`` groups are captured in :variable:`CMAKE_MATCH_<n>` variables.
 
 
+.. _LESS:
+
 ``if(<variable|string> LESS <variable|string>)``
 ``if(<variable|string> LESS <variable|string>)``
  True if the given string or variable's value is a valid number and less
  True if the given string or variable's value is a valid number and less
  than that on the right.
  than that on the right.
 
 
+.. _GREATER:
+
 ``if(<variable|string> GREATER <variable|string>)``
 ``if(<variable|string> GREATER <variable|string>)``
  True if the given string or variable's value is a valid number and greater
  True if the given string or variable's value is a valid number and greater
  than that on the right.
  than that on the right.
 
 
+.. _EQUAL:
+
 ``if(<variable|string> EQUAL <variable|string>)``
 ``if(<variable|string> EQUAL <variable|string>)``
  True if the given string or variable's value is a valid number and equal
  True if the given string or variable's value is a valid number and equal
  to that on the right.
  to that on the right.
 
 
+.. _LESS_EQUAL:
+
 ``if(<variable|string> LESS_EQUAL <variable|string>)``
 ``if(<variable|string> LESS_EQUAL <variable|string>)``
  .. versionadded:: 3.7
  .. versionadded:: 3.7
   True if the given string or variable's value is a valid number and less
   True if the given string or variable's value is a valid number and less
   than or equal to that on the right.
   than or equal to that on the right.
 
 
+.. _GREATER_EQUAL:
+
 ``if(<variable|string> GREATER_EQUAL <variable|string>)``
 ``if(<variable|string> GREATER_EQUAL <variable|string>)``
  .. versionadded:: 3.7
  .. versionadded:: 3.7
   True if the given string or variable's value is a valid number and greater
   True if the given string or variable's value is a valid number and greater
   than or equal to that on the right.
   than or equal to that on the right.
 
 
+.. _STRLESS:
+
 ``if(<variable|string> STRLESS <variable|string>)``
 ``if(<variable|string> STRLESS <variable|string>)``
  True if the given string or variable's value is lexicographically less
  True if the given string or variable's value is lexicographically less
  than the string or variable on the right.
  than the string or variable on the right.
 
 
+.. _STRGREATER:
+
 ``if(<variable|string> STRGREATER <variable|string>)``
 ``if(<variable|string> STRGREATER <variable|string>)``
  True if the given string or variable's value is lexicographically greater
  True if the given string or variable's value is lexicographically greater
  than the string or variable on the right.
  than the string or variable on the right.
 
 
+.. _STREQUAL:
+
 ``if(<variable|string> STREQUAL <variable|string>)``
 ``if(<variable|string> STREQUAL <variable|string>)``
  True if the given string or variable's value is lexicographically equal
  True if the given string or variable's value is lexicographically equal
  to the string or variable on the right.
  to the string or variable on the right.
 
 
+.. _STRLESS_EQUAL:
+
 ``if(<variable|string> STRLESS_EQUAL <variable|string>)``
 ``if(<variable|string> STRLESS_EQUAL <variable|string>)``
  .. versionadded:: 3.7
  .. versionadded:: 3.7
   True if the given string or variable's value is lexicographically less
   True if the given string or variable's value is lexicographically less
   than or equal to the string or variable on the right.
   than or equal to the string or variable on the right.
 
 
+.. _STRGREATER_EQUAL:
+
 ``if(<variable|string> STRGREATER_EQUAL <variable|string>)``
 ``if(<variable|string> STRGREATER_EQUAL <variable|string>)``
  .. versionadded:: 3.7
  .. versionadded:: 3.7
   True if the given string or variable's value is lexicographically greater
   True if the given string or variable's value is lexicographically greater
@@ -200,24 +234,32 @@ Comparisons
 Version Comparisons
 Version Comparisons
 """""""""""""""""""
 """""""""""""""""""
 
 
+.. _VERSION_LESS:
+
 ``if(<variable|string> VERSION_LESS <variable|string>)``
 ``if(<variable|string> VERSION_LESS <variable|string>)``
  Component-wise integer version number comparison (version format is
  Component-wise integer version number comparison (version format is
  ``major[.minor[.patch[.tweak]]]``, omitted components are treated as zero).
  ``major[.minor[.patch[.tweak]]]``, omitted components are treated as zero).
  Any non-integer version component or non-integer trailing part of a version
  Any non-integer version component or non-integer trailing part of a version
  component effectively truncates the string at that point.
  component effectively truncates the string at that point.
 
 
+.. _VERSION_GREATER:
+
 ``if(<variable|string> VERSION_GREATER <variable|string>)``
 ``if(<variable|string> VERSION_GREATER <variable|string>)``
  Component-wise integer version number comparison (version format is
  Component-wise integer version number comparison (version format is
  ``major[.minor[.patch[.tweak]]]``, omitted components are treated as zero).
  ``major[.minor[.patch[.tweak]]]``, omitted components are treated as zero).
  Any non-integer version component or non-integer trailing part of a version
  Any non-integer version component or non-integer trailing part of a version
  component effectively truncates the string at that point.
  component effectively truncates the string at that point.
 
 
+.. _VERSION_EQUAL:
+
 ``if(<variable|string> VERSION_EQUAL <variable|string>)``
 ``if(<variable|string> VERSION_EQUAL <variable|string>)``
  Component-wise integer version number comparison (version format is
  Component-wise integer version number comparison (version format is
  ``major[.minor[.patch[.tweak]]]``, omitted components are treated as zero).
  ``major[.minor[.patch[.tweak]]]``, omitted components are treated as zero).
  Any non-integer version component or non-integer trailing part of a version
  Any non-integer version component or non-integer trailing part of a version
  component effectively truncates the string at that point.
  component effectively truncates the string at that point.
 
 
+.. _VERSION_LESS_EQUAL:
+
 ``if(<variable|string> VERSION_LESS_EQUAL <variable|string>)``
 ``if(<variable|string> VERSION_LESS_EQUAL <variable|string>)``
  .. versionadded:: 3.7
  .. versionadded:: 3.7
   Component-wise integer version number comparison (version format is
   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
   Any non-integer version component or non-integer trailing part of a version
   component effectively truncates the string at that point.
   component effectively truncates the string at that point.
 
 
+.. _VERSION_GREATER_EQUAL:
+
 ``if(<variable|string> VERSION_GREATER_EQUAL <variable|string>)``
 ``if(<variable|string> VERSION_GREATER_EQUAL <variable|string>)``
  .. versionadded:: 3.7
  .. versionadded:: 3.7
   Component-wise integer version number comparison (version format is
   Component-wise integer version number comparison (version format is