mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-07 06:09:52 -06:00
Merge topic 'add-extra-boolean-comparisons'
02d177c9 Add additional <= and >= comparison operators
This commit is contained in:
@@ -30,10 +30,12 @@ else and endif clause is optional. Long expressions can be used and
|
||||
there is a traditional order of precedence. Parenthetical expressions
|
||||
are evaluated first followed by unary tests such as ``EXISTS``,
|
||||
``COMMAND``, and ``DEFINED``. Then any binary tests such as
|
||||
``EQUAL``, ``LESS``, ``GREATER``, ``STRLESS``, ``STRGREATER``,
|
||||
``STREQUAL``, and ``MATCHES`` will be evaluated. Then boolean ``NOT``
|
||||
operators and finally boolean ``AND`` and then ``OR`` operators will
|
||||
be evaluated.
|
||||
``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`` will be evaluated. Then boolean ``NOT`` operators and
|
||||
finally boolean ``AND`` and then ``OR`` operators will be evaluated.
|
||||
|
||||
Possible expressions are:
|
||||
|
||||
@@ -115,6 +117,14 @@ Possible expressions are:
|
||||
True if the given string or variable's value is a valid number and equal
|
||||
to that on the right.
|
||||
|
||||
``if(<variable|string> LESS_EQUAL <variable|string>)``
|
||||
True if the given string or variable's value is a valid number and less
|
||||
than or equal to that on the right.
|
||||
|
||||
``if(<variable|string> GREATER_EQUAL <variable|string>)``
|
||||
True if the given string or variable's value is a valid number and greater
|
||||
than or equal to that on the right.
|
||||
|
||||
``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.
|
||||
@@ -127,15 +137,31 @@ Possible expressions are:
|
||||
True if the given string or variable's value is lexicographically equal
|
||||
to the string or variable on the right.
|
||||
|
||||
``if(<variable|string> STRLESS_EQUAL <variable|string>)``
|
||||
True if the given string or variable's value is lexicographically less
|
||||
than or equal to the string or variable on the right.
|
||||
|
||||
``if(<variable|string> STRGREATER_EQUAL <variable|string>)``
|
||||
True if the given string or variable's value is lexicographically greater
|
||||
than or equal to the string or variable on the right.
|
||||
|
||||
``if(<variable|string> VERSION_LESS <variable|string>)``
|
||||
Component-wise integer version number comparison (version format is
|
||||
``major[.minor[.patch[.tweak]]]``).
|
||||
|
||||
``if(<variable|string> VERSION_GREATER <variable|string>)``
|
||||
Component-wise integer version number comparison (version format is
|
||||
``major[.minor[.patch[.tweak]]]``).
|
||||
|
||||
``if(<variable|string> VERSION_EQUAL <variable|string>)``
|
||||
Component-wise integer version number comparison (version format is
|
||||
``major[.minor[.patch[.tweak]]]``).
|
||||
|
||||
``if(<variable|string> VERSION_GREATER <variable|string>)``
|
||||
``if(<variable|string> VERSION_LESS_EQUAL <variable|string>)``
|
||||
Component-wise integer version number comparison (version format is
|
||||
``major[.minor[.patch[.tweak]]]``).
|
||||
|
||||
``if(<variable|string> VERSION_GREATER_EQUAL <variable|string>)``
|
||||
Component-wise integer version number comparison (version format is
|
||||
``major[.minor[.patch[.tweak]]]``).
|
||||
|
||||
@@ -186,20 +212,21 @@ above-documented signature accepts ``<variable|string>``:
|
||||
* If the left hand argument to ``MATCHES`` is missing it returns false
|
||||
without error
|
||||
|
||||
* Both left and right hand arguments to ``LESS``, ``GREATER``, and
|
||||
``EQUAL`` are independently tested to see if they are defined
|
||||
variables, if so their defined values are used otherwise the original
|
||||
value is used.
|
||||
* Both left and right hand arguments to ``LESS``, ``GREATER``, ``EQUAL``,
|
||||
``LESS_EQUAL``, and ``GREATER_EQUAL``, are independently tested to see if
|
||||
they are defined variables, if so their defined values are used otherwise
|
||||
the original value is used.
|
||||
|
||||
* Both left and right hand arguments to ``STRLESS``, ``STREQUAL``, and
|
||||
``STRGREATER`` are independently tested to see if they are defined
|
||||
variables, if so their defined values are used otherwise the original
|
||||
value is used.
|
||||
* Both left and right hand arguments to ``STRLESS``, ``STRGREATER``,
|
||||
``STREQUAL``, ``STRLESS_EQUAL``, and ``STRGREATER_EQUAL`` are independently
|
||||
tested to see if they are defined variables, if so their defined values are
|
||||
used otherwise the original value is used.
|
||||
|
||||
* Both left and right hand arguments to ``VERSION_LESS``,
|
||||
``VERSION_EQUAL``, and ``VERSION_GREATER`` are independently tested
|
||||
to see if they are defined variables, if so their defined values are
|
||||
used otherwise the original value is used.
|
||||
``VERSION_GREATER``, ``VERSION_EQUAL``, ``VERSION_LESS_EQUAL``, and
|
||||
``VERSION_GREATER_EQUAL`` are independently tested to see if they are defined
|
||||
variables, if so their defined values are used otherwise the original value
|
||||
is used.
|
||||
|
||||
* The right hand argument to ``NOT`` is tested to see if it is a boolean
|
||||
constant, if so the value is used, otherwise it is assumed to be a
|
||||
|
||||
@@ -197,10 +197,12 @@ Comparison
|
||||
|
||||
::
|
||||
|
||||
string(COMPARE EQUAL <string1> <string2> <output variable>)
|
||||
string(COMPARE NOTEQUAL <string1> <string2> <output variable>)
|
||||
string(COMPARE LESS <string1> <string2> <output variable>)
|
||||
string(COMPARE GREATER <string1> <string2> <output variable>)
|
||||
string(COMPARE EQUAL <string1> <string2> <output variable>)
|
||||
string(COMPARE NOTEQUAL <string1> <string2> <output variable>)
|
||||
string(COMPARE LESS_EQUAL <string1> <string2> <output variable>)
|
||||
string(COMPARE GREATER_EQUAL <string1> <string2> <output variable>)
|
||||
|
||||
Compare the strings and store true or false in the output variable.
|
||||
|
||||
|
||||
@@ -66,12 +66,16 @@ Available logical expressions are:
|
||||
``1`` if the CMake-id of the C compiler matches ``comp``, otherwise ``0``.
|
||||
``$<CXX_COMPILER_ID:comp>``
|
||||
``1`` if the CMake-id of the CXX compiler matches ``comp``, otherwise ``0``.
|
||||
``$<VERSION_GREATER:v1,v2>``
|
||||
``1`` if ``v1`` is a version greater than ``v2``, else ``0``.
|
||||
``$<VERSION_LESS:v1,v2>``
|
||||
``1`` if ``v1`` is a version less than ``v2``, else ``0``.
|
||||
``$<VERSION_GREATER:v1,v2>``
|
||||
``1`` if ``v1`` is a version greater than ``v2``, else ``0``.
|
||||
``$<VERSION_EQUAL:v1,v2>``
|
||||
``1`` if ``v1`` is the same version as ``v2``, else ``0``.
|
||||
``$<VERSION_LESS_EQUAL:v1,v2>``
|
||||
``1`` if ``v1`` is a version less than or equal to ``v2``, else ``0``.
|
||||
``$<VERSION_GREATER_EQUAL:v1,v2>``
|
||||
``1`` if ``v1`` is a version greater than or equal to ``v2``, else ``0``.
|
||||
``$<C_COMPILER_VERSION:ver>``
|
||||
``1`` if the version of the C compiler matches ``ver``, otherwise ``0``.
|
||||
``$<CXX_COMPILER_VERSION:ver>``
|
||||
|
||||
6
Help/release/dev/add-extra-boolean-comparisons.rst
Normal file
6
Help/release/dev/add-extra-boolean-comparisons.rst
Normal file
@@ -0,0 +1,6 @@
|
||||
add-extra-boolean-comparisons
|
||||
-----------------------------
|
||||
|
||||
* The :command:`if` command gained new boolean comparison operations
|
||||
``LESS_EQUAL``, ``GREATER_EQUAL``, ``STRLESS_EQUAL``, ``STRGREATER_EQUAL``,
|
||||
``VERSION_LESS_EQUAL``, and ``VERSION_GREATER_EQUAL``.
|
||||
@@ -26,11 +26,11 @@ Individual component values are also available in variables:
|
||||
* :variable:`CMAKE_PATCH_VERSION`
|
||||
* :variable:`CMAKE_TWEAK_VERSION`
|
||||
|
||||
Use the :command:`if` command ``VERSION_LESS``, ``VERSION_EQUAL``, or
|
||||
``VERSION_GREATER`` operators to compare version string values against
|
||||
``CMAKE_VERSION`` using a component-wise test. Version component
|
||||
values may be 10 or larger so do not attempt to compare version
|
||||
strings as floating-point numbers.
|
||||
Use the :command:`if` command ``VERSION_LESS``, ``VERSION_GREATER``,
|
||||
``VERSION_EQUAL``, ``VERSION_LESS_EQUAL``, or ``VERSION_GREATER_EQUAL``
|
||||
operators to compare version string values against ``CMAKE_VERSION`` using a
|
||||
component-wise test. Version component values may be 10 or larger so do not
|
||||
attempt to compare version strings as floating-point numbers.
|
||||
|
||||
.. note::
|
||||
|
||||
|
||||
Reference in New Issue
Block a user