Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
CMake
CMake
Commits
22140f7a
Commit
22140f7a
authored
Jan 25, 2021
by
Michael Hirsch
Committed by
Brad King
Feb 18, 2021
2
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Help: Add internal links to if() docs
parent
50fc9d5b
Pipeline
#214884
waiting for manual action with stages
in 5 minutes and 17 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
7 deletions
+51
-7
Help/command/if.rst
Help/command/if.rst
+51
-7
No files found.
Help/command/if.rst
View file @
22140f7a
...
...
@@ -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
...
...
Brad King
@brad.king
mentioned in commit
bc94ff79
·
Feb 18, 2021
mentioned in commit
bc94ff79
mentioned in commit bc94ff79452a40b6bf734f9e2b6046d23ea9d5b3
Toggle commit list
Brad King
@brad.king
mentioned in commit
0ee997b1
·
Feb 18, 2021
mentioned in commit
0ee997b1
mentioned in commit 0ee997b1323a6f8f3cbe0eecea558adc494c3fb0
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment