diff options
author | Brad King <brad.king@kitware.com> | 2022-06-06 13:47:37 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-06-06 13:47:45 (GMT) |
commit | ab1edff49268df77e1cdcf8074e24e64ef140370 (patch) | |
tree | 7d7f553823bc5581ec28df764d23269a95d9b97e /Help | |
parent | 9fdade1d6b1f62cbb24e0bdf79b98d72145ba17f (diff) | |
parent | be4b9e10afaae750ad184ce1b34d6cb2c3d7fd33 (diff) | |
download | CMake-ab1edff49268df77e1cdcf8074e24e64ef140370.zip CMake-ab1edff49268df77e1cdcf8074e24e64ef140370.tar.gz CMake-ab1edff49268df77e1cdcf8074e24e64ef140370.tar.bz2 |
Merge topic 'if-command-PATH_EQUAL'
be4b9e10af if command: Add PATH_EQUAL operator
Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !7321
Diffstat (limited to 'Help')
-rw-r--r-- | Help/command/if.rst | 30 | ||||
-rw-r--r-- | Help/manual/cmake-policies.7.rst | 1 | ||||
-rw-r--r-- | Help/policy/CMP0139.rst | 17 | ||||
-rw-r--r-- | Help/release/dev/if-PATH_EQUAL.rst | 5 |
4 files changed, 52 insertions, 1 deletions
diff --git a/Help/command/if.rst b/Help/command/if.rst index 64f1c35..c096725 100644 --- a/Help/command/if.rst +++ b/Help/command/if.rst @@ -47,7 +47,7 @@ Compound conditions are evaluated in the following order of precedence: `GREATER_EQUAL`_, `STREQUAL`_, `STRLESS`_, `STRLESS_EQUAL`_, `STRGREATER`_, `STRGREATER_EQUAL`_, `VERSION_EQUAL`_, `VERSION_LESS`_, `VERSION_LESS_EQUAL`_, `VERSION_GREATER`_, `VERSION_GREATER_EQUAL`_, - and `MATCHES`_. + `PATH_EQUAL`_, and `MATCHES`_. 4. Unary logical operator `NOT`_. @@ -314,6 +314,34 @@ Version Comparisons Any non-integer version component or non-integer trailing part of a version component effectively truncates the string at that point. +Path Comparisons +"""""""""""""""" + +.. _PATH_EQUAL: + +``if(<variable|string> PATH_EQUAL <variable|string>)`` + .. versionadded:: 3.24 + Compares the lexical representations of two paths provided as string + literals or variables. No normalization is performed on either path. + + Lexical comparison has the advantage over string comparison to have a + knowledge of the structure of the path. So, the following comparison is + ``TRUE`` using ``PATH_EQUAL`` operator, but ``FALSE`` with ``STREQUAL``: + + .. code-block:: cmake + + # comparison is TRUE + if ("/a//b/c" PATH_EQUAL "/a/b/c") + ... + endif() + + # comparison is FALSE + if ("/a//b/c" STREQUAL "/a/b/c") + ... + endif() + + See :ref:`cmake_path(COMPARE) <Path COMPARE>` for more details. + Variable Expansion ^^^^^^^^^^^^^^^^^^ diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index a7741f7..1447c17 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -58,6 +58,7 @@ Policies Introduced by CMake 3.24 .. toctree:: :maxdepth: 1 + CMP0139: The if() command supports path comparisons using PATH_EQUAL operator. </policy/CMP0139> CMP0138: MSVC compilers use -ZI instead of /Zi for x86 and x64 by default. </policy/CMP0138> CMP0137: try_compile() passes platform variables in project mode. </policy/CMP0137> CMP0136: Watcom runtime library flags are selected by an abstraction. </policy/CMP0136> diff --git a/Help/policy/CMP0139.rst b/Help/policy/CMP0139.rst new file mode 100644 index 0000000..5a0f4f7 --- /dev/null +++ b/Help/policy/CMP0139.rst @@ -0,0 +1,17 @@ +CMP0139 +------- + +.. versionadded:: 3.24 + +The :command:`if` command supports path comparisons using ``PATH_EQUAL`` +operator. + +The ``OLD`` behavior for this policy is to ignore the ``PATH_EQUAL`` operator. +The ``NEW`` behavior is to interpret the ``PATH_EQUAL`` operator. + +This policy was introduced in CMake version 3.24. +CMake version |release| warns when the policy is not set and uses +``OLD`` behavior. Use the :command:`cmake_policy` command to set +it to ``OLD`` or ``NEW`` explicitly. + +.. include:: DEPRECATED.txt diff --git a/Help/release/dev/if-PATH_EQUAL.rst b/Help/release/dev/if-PATH_EQUAL.rst new file mode 100644 index 0000000..45f02e8 --- /dev/null +++ b/Help/release/dev/if-PATH_EQUAL.rst @@ -0,0 +1,5 @@ +if-PATH_EQUAL +------------- + +* The :command:`if` command gains the capability to compare paths by using the + ``PATH_EQUAL`` operator. See policy :policy:`CMP0139`. |