Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
CMake
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tom James
CMake
Commits
22140f7a
Commit
22140f7a
authored
4 years ago
by
scivision
Committed by
Brad King
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Help: Add internal links to if() docs
parent
50fc9d5b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Help/command/if.rst
+51
-7
51 additions, 7 deletions
Help/command/if.rst
with
51 additions
and
7 deletions
Help/command/if.rst
+
51
−
7
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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment