diff options
author | Craig Scott <craig.scott@crascit.com> | 2020-11-14 11:39:21 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-11-14 11:39:42 (GMT) |
commit | eb04e25ba6dc6c273de138abd044baa4efb0482b (patch) | |
tree | 2e56aceae2e561197989bddba28671eb3be2b578 | |
parent | 5501958d16c978e33d8b813714561226837977b7 (diff) | |
parent | ed21ad181e0c3fd9fc1a8094fc2f8b8daafefc6d (diff) | |
download | CMake-eb04e25ba6dc6c273de138abd044baa4efb0482b.zip CMake-eb04e25ba6dc6c273de138abd044baa4efb0482b.tar.gz CMake-eb04e25ba6dc6c273de138abd044baa4efb0482b.tar.bz2 |
Merge topic 'cmake_path-enhancements'
ed21ad181e cmake_path: various enhancements to subcommands/keywords
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5457
17 files changed, 130 insertions, 209 deletions
diff --git a/Help/command/cmake_path.rst b/Help/command/cmake_path.rst index cb84dd1..2d37ae0 100644 --- a/Help/command/cmake_path.rst +++ b/Help/command/cmake_path.rst @@ -1,7 +1,7 @@ cmake_path ---------- -.. versionadded:: 3.19 +.. versionadded:: 3.20 Filesystem path manipulation command. @@ -66,8 +66,8 @@ The following exceptions apply: in cross-compiling environment. For all commands, ``<path-var>`` placeholder expect a variable name. An error -will be raised if the variable does not exist, except for `APPEND`_ and -`CMAKE_PATH`_ sub-commands. ``<input>`` placeholder expect a string literal. +will be raised if the variable does not exist, except for `SET`_ and `APPEND`_ +sub-commands. ``<input>`` placeholder expect a string literal. ``[<input>...]`` placeholder expect zero or more arguments. ``<out-var>`` placeholder expect a variable name. @@ -79,10 +79,10 @@ placeholder expect a variable name. To initialize a path variable, three possibilities can be used: 1. :command:`set` command. -2. :ref:`cmake_path(APPEND) <APPEND>` command. Can be used to build a path from - already available path fragments. -3. :ref:`cmake_path(CMAKE_PATH) <CMAKE_PATH>` command. Mainly used to build a +2. :ref:`cmake_path(SET) <SET>` command. Mainly used to build a path variable from a native path. +3. :ref:`cmake_path(APPEND) <APPEND>` command. Can be used to build a path from + already available path fragments. .. code-block:: cmake @@ -90,13 +90,13 @@ To initialize a path variable, three possibilities can be used: set (path1 "${CMAKE_CURRENT_SOURCE_DIR}/data") - cmake_path(APPEND path2 "${CMAKE_CURRENT_SOURCE_DIR}" "data") + cmake_path(SET path2 "${CMAKE_CURRENT_SOURCE_DIR}/data") - cmake_path(CMAKE_PATH path3 "${CMAKE_CURRENT_SOURCE_DIR}/data") + cmake_path(APPEND path3 "${CMAKE_CURRENT_SOURCE_DIR}" "data") `Modification`_ and `Generation`_ sub-commands store the result in-place or in -the variable specified by ``OUTPUT_VARIABLE`` option. All other sub-commands, -except `CMAKE_PATH`_, store the result in the required ``<out-var>`` variable. +the variable specified by ``OUTPUT_VARIABLE`` option. All other sub-commands +store the result in the required ``<out-var>`` variable. Sub-commands supporting ``NORMALIZE`` option will :ref:`normalize <NORMAL_PATH>` the path. @@ -117,8 +117,9 @@ Synopsis cmake_path(`GET`_ <path-var> :ref:`PARENT_PATH <GET_PARENT_PATH>` <out-var>) `Modification`_ + cmake_path(`SET`_ <path-var> [NORMALIZE] <input>) cmake_path(`APPEND`_ <path-var> [<input>...] [OUTPUT_VARIABLE <out-var>]) - cmake_path(`CONCAT`_ <path-var> [<input>...] [OUTPUT_VARIABLE <out-var>]) + cmake_path(`APPEND_STRING`_ <path-var> [<input>...] [OUTPUT_VARIABLE <out-var>]) cmake_path(`REMOVE_FILENAME`_ <path-var> [OUTPUT_VARIABLE <out-var>]) cmake_path(`REPLACE_FILENAME`_ <path-var> <input> [OUTPUT_VARIABLE <out-var>]) cmake_path(`REMOVE_EXTENSION`_ <path-var> [LAST_ONLY] @@ -130,19 +131,16 @@ Synopsis cmake_path(`NORMAL_PATH`_ <path-var> [OUTPUT_VARIABLE <out-var>]) cmake_path(`RELATIVE_PATH`_ <path-var> [BASE_DIRECTORY <input>] [OUTPUT_VARIABLE <out-var>]) - cmake_path(`PROXIMATE_PATH`_ <path-var> [BASE_DIRECTORY <input>] - [OUTPUT_VARIABLE <out-var>]) cmake_path(`ABSOLUTE_PATH`_ <path-var> [BASE_DIRECTORY <input>] [NORMALIZE] [OUTPUT_VARIABLE <out-var>]) `Conversion`_ - cmake_path(`CMAKE_PATH`_ <path-var> [NORMALIZE] <input>) cmake_path(`NATIVE_PATH`_ <path-var> [NORMALIZE] <out-var>) cmake_path(`CONVERT`_ <input> `TO_CMAKE_PATH_LIST`_ <out-var>) cmake_path(`CONVERT`_ <input> `TO_NATIVE_PATH_LIST`_ <out-var>) `Comparison`_ - cmake_path(`COMPARE`_ <path-var> <OP> <input> <out-var>) + cmake_path(`COMPARE`_ <input1> <OP> <input2> <out-var>) `Query`_ cmake_path(`HAS_ROOT_NAME`_ <path-var> <out-var>) @@ -388,6 +386,36 @@ For Example: Modification ^^^^^^^^^^^^ +.. _cmake_path-SET: +.. _SET: + +.. code-block:: cmake + + cmake_path(SET <path-var> [NORMALIZE] <input>) + +Assign the ``<input>`` path to ``<path-var>``. Moreover, if ``<input>`` is a +native path, it is converted into cmake-style path with forward-slashes +(``/``). On Windows, the long filename marker is taken into account. + +When ``NORMALIZE`` option is specified, the path is :ref:`normalized +<NORMAL_PATH>` before the conversion. + +For Example: + + .. code-block:: cmake + + set (native_path "c:\\a\\b/..\\c") + cmake_path (SET path "${native_path}") + message ("CMake path is \"${path}\"") + + cmake_path (SET path NORMALIZE "${native_path}") + message ("Normalized CMake path is \"${path}\"") + + Will display:: + + CMake path is "c:/a/b/../c" + Normalized CMake path is "c:/a/c" + .. _APPEND: .. code-block:: cmake @@ -419,13 +447,13 @@ For each ``<input>`` argument, the following algorithm (pseudo-code) applies: appends <input> omitting any root-name to <path> -.. _CONCAT: +.. _APPEND_STRING: .. code-block:: cmake - cmake_path(CONCAT <path-var> [<input>...] [OUTPUT_VARIABLE <out-var>]) + cmake_path(APPEND_STRING <path-var> [<input>...] [OUTPUT_VARIABLE <out-var>]) -Concatenates all the ``<input>`` arguments to the ``<path-var>`` without +Append all the ``<input>`` arguments to the ``<path-var>`` without ``directory-separator``. .. _REMOVE_FILENAME: @@ -500,7 +528,7 @@ Replaces the :ref:`extension <EXTENSION_DEF>` with ``<input>``. (`HAS_EXTENSION`_ is true), it is removed. 2. A ``dot`` character is appended to ``<path-var>``, if ``<input>`` is not empty or does not begin with a ``dot`` character. - 3. ``<input>`` is appended as if `CONCAT`_ was used. + 3. ``<input>`` is appended as if `APPEND_STRING`_ was used. Equivalent to the following: @@ -509,9 +537,9 @@ Equivalent to the following: cmake_path(REMOVE_EXTENSION path) if (NOT "input" MATCHES "^\\.") - cmake_path(CONCAT path ".") + cmake_path(APPEND_STRING path ".") endif() - cmake_path(CONCAT path "input"); + cmake_path(APPEND_STRING path "input"); Generation ^^^^^^^^^^ @@ -557,19 +585,6 @@ Returns ``<path-var>`` made relative to ``BASE_DIRECTORY`` argument. If For reference, the algorithm used to compute the relative path is described `here <https://en.cppreference.com/w/cpp/filesystem/path/lexically_normal>`_. -.. _PROXIMATE_PATH: - -.. code-block:: cmake - - cmake_path(PROXIMATE_PATH <path-var> [BASE_DIRECTORY <input>] - [OUTPUT_VARIABLE <out-var>]) - -If the value of `RELATIVE_PATH`_ is not an empty path, return -it. Otherwise return ``<path-var>``. - -If ``BASE_DIRECTORY`` is not specified, the default base directory will be -:variable:`CMAKE_CURRENT_SOURCE_DIR`. - .. _ABSOLUTE_PATH: .. code-block:: cmake @@ -593,35 +608,6 @@ command. Conversion ^^^^^^^^^^ -.. _cmake_path-CMAKE_PATH: -.. _CMAKE_PATH: - -.. code-block:: cmake - - cmake_path(CMAKE_PATH <path-var> [NORMALIZE] <input>) - -Converts a native ``<input>`` path into cmake-style path with forward-slashes -(``/``). On Windows, the long filename marker is taken into account. - -When ``NORMALIZE`` option is specified, the path is :ref:`normalized -<NORMAL_PATH>` before the conversion. - -For Example: - - .. code-block:: cmake - - set (native_path "c:\\a\\b/..\\c") - cmake_path (CMAKE_PATH path "${native_path}") - message ("CMake path is \"${path}\"") - - cmake_path (CMAKE_PATH path NORMALIZE "${native_path}") - message ("Normalized CMake path is \"${path}\"") - - Will display:: - - CMake path is "c:/a/b/../c" - Normalized CMake path is "c:/a/c" - .. _cmake_path-NATIVE_PATH: .. _NATIVE_PATH: @@ -644,9 +630,9 @@ When ``NORMALIZE`` option is specified, the path is :ref:`normalized cmake_path(CONVERT <input> TO_CMAKE_PATH_LIST <out-var> [NORMALIZE]) Converts a native ``<input>`` path into cmake-style path with forward-slashes -(``/``). On Windows, the long filename marker is taken into account. The input can -be a single path or a system search path like ``$ENV{PATH}``. A search path -will be converted to a cmake-style list separated by ``;`` characters. The +(``/``). On Windows, the long filename marker is taken into account. The input +can be a single path or a system search path like ``$ENV{PATH}``. A search +path will be converted to a cmake-style list separated by ``;`` characters. The result of the conversion is stored in the ``<out-var>`` variable. When ``NORMALIZE`` option is specified, the path is :ref:`normalized @@ -691,8 +677,8 @@ Comparison .. code-block:: cmake - cmake_path(COMPARE <path-var> EQUAL <input> <out-var>) - cmake_path(COMPARE <path-var> NOT_EQUAL <input> <out-var>) + cmake_path(COMPARE <input1> EQUAL <input2> <out-var>) + cmake_path(COMPARE <input1> NOT_EQUAL <input2> <out-var>) Compares the lexical representations of the path and another path. @@ -700,16 +686,14 @@ For testing equality, the following algorithm (pseudo-code) apply: .. code-block:: cmake - # <path> is the contents of <path-var> - - IF (NOT <path>.root_name() STREQUAL <input>.root_name()) + IF (NOT <input1>.root_name() STREQUAL <input2>.root_name()) returns FALSE - ELSEIF (<path>.has_root_directory() XOR <input>.has_root_directory()) + ELSEIF (<input1>.has_root_directory() XOR <input2>.has_root_directory()) returns FALSE ENDIF() - returns TRUE or FALSE if the relative portion of <path> is - lexicographically equal or not to the relative portion of <input>. + returns TRUE or FALSE if the relative portion of <input1> is + lexicographically equal or not to the relative portion of <input2>. Comparison is performed path component-wise Query diff --git a/Source/cmCMakePathCommand.cxx b/Source/cmCMakePathCommand.cxx index 720f582..85e7d9e 100644 --- a/Source/cmCMakePathCommand.cxx +++ b/Source/cmCMakePathCommand.cxx @@ -250,9 +250,48 @@ bool HandleGetCommand(std::vector<std::string> const& args, return true; } +bool HandleSetCommand(std::vector<std::string> const& args, + cmExecutionStatus& status) +{ + if (args.size() < 3 || args.size() > 4) { + status.SetError("SET must be called with two or three arguments."); + return false; + } + + if (args[1].empty()) { + status.SetError("Invalid name for path variable."); + return false; + } + + static NormalizeParser const parser; + + const auto arguments = parser.Parse(args); + + if (parser.GetInputs().size() != 1) { + status.SetError("SET called with unexpected arguments."); + return false; + } + + auto path = + cmCMakePath(parser.GetInputs().front(), cmCMakePath::native_format); + + if (arguments.Normalize) { + path = path.Normal(); + } + + status.GetMakefile().AddDefinition(args[1], path.GenericString()); + + return true; +} + bool HandleAppendCommand(std::vector<std::string> const& args, cmExecutionStatus& status) { + if (args[1].empty()) { + status.SetError("Invalid name for path variable."); + return false; + } + static OutputVariableParser const parser{}; const auto arguments = parser.Parse(args); @@ -272,8 +311,8 @@ bool HandleAppendCommand(std::vector<std::string> const& args, return true; } -bool HandleConcatCommand(std::vector<std::string> const& args, - cmExecutionStatus& status) +bool HandleAppendStringCommand(std::vector<std::string> const& args, + cmExecutionStatus& status) { static OutputVariableParser const parser{}; @@ -546,16 +585,6 @@ bool HandleRelativePathCommand(std::vector<std::string> const& args, }); } -bool HandleProximatePathCommand(std::vector<std::string> const& args, - cmExecutionStatus& status) -{ - return HandleTransformPathCommand( - args, status, - [](const cmCMakePath& path, const std::string& base) -> cmCMakePath { - return path.Proximate(base); - }); -} - bool HandleAbsolutePathCommand(std::vector<std::string> const& args, cmExecutionStatus& status) { @@ -567,40 +596,6 @@ bool HandleAbsolutePathCommand(std::vector<std::string> const& args, true); } -bool HandleCMakePathCommand(std::vector<std::string> const& args, - cmExecutionStatus& status) -{ - if (args.size() < 3 || args.size() > 4) { - status.SetError("CMAKE_PATH must be called with two or three arguments."); - return false; - } - - static NormalizeParser const parser; - - const auto arguments = parser.Parse(args); - - if (parser.GetInputs().size() != 1) { - status.SetError("CMAKE_PATH called with unexpected arguments."); - return false; - } - - if (args[1].empty()) { - status.SetError("Invalid name for output variable."); - return false; - } - - auto path = - cmCMakePath(parser.GetInputs().front(), cmCMakePath::native_format); - - if (arguments.Normalize) { - path = path.Normal(); - } - - status.GetMakefile().AddDefinition(args[1], path.GenericString()); - - return true; -} - bool HandleNativePathCommand(std::vector<std::string> const& args, cmExecutionStatus& status) { @@ -737,12 +732,7 @@ bool HandleCompareCommand(std::vector<std::string> const& args, return false; } - std::string inputPath; - if (!getInputPath(args[1], status, inputPath)) { - return false; - } - - cmCMakePath path1(inputPath); + cmCMakePath path1(args[1]); cmCMakePath path2(args[3]); auto result = op->second(path1, path2); @@ -987,17 +977,16 @@ bool cmCMakePathCommand(std::vector<std::string> const& args, static cmSubcommandTable const subcommand{ { "GET"_s, HandleGetCommand }, + { "SET"_s, HandleSetCommand }, { "APPEND"_s, HandleAppendCommand }, - { "CONCAT"_s, HandleConcatCommand }, + { "APPEND_STRING"_s, HandleAppendStringCommand }, { "REMOVE_FILENAME"_s, HandleRemoveFilenameCommand }, { "REPLACE_FILENAME"_s, HandleReplaceFilenameCommand }, { "REMOVE_EXTENSION"_s, HandleRemoveExtensionCommand }, { "REPLACE_EXTENSION"_s, HandleReplaceExtensionCommand }, { "NORMAL_PATH"_s, HandleNormalPathCommand }, { "RELATIVE_PATH"_s, HandleRelativePathCommand }, - { "PROXIMATE_PATH"_s, HandleProximatePathCommand }, { "ABSOLUTE_PATH"_s, HandleAbsolutePathCommand }, - { "CMAKE_PATH"_s, HandleCMakePathCommand }, { "NATIVE_PATH"_s, HandleNativePathCommand }, { "CONVERT"_s, HandleConvertCommand }, { "COMPARE"_s, HandleCompareCommand }, diff --git a/Tests/RunCMake/cmake_path/CONCAT-wrong-path-result.txt b/Tests/RunCMake/cmake_path/APPEND_STRING-OUTPUT_VARIABLE-invalid-arg-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/cmake_path/CONCAT-wrong-path-result.txt +++ b/Tests/RunCMake/cmake_path/APPEND_STRING-OUTPUT_VARIABLE-invalid-arg-result.txt diff --git a/Tests/RunCMake/cmake_path/CONCAT-OUTPUT_VARIABLE-no-arg-result.txt b/Tests/RunCMake/cmake_path/APPEND_STRING-OUTPUT_VARIABLE-no-arg-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/cmake_path/CONCAT-OUTPUT_VARIABLE-no-arg-result.txt +++ b/Tests/RunCMake/cmake_path/APPEND_STRING-OUTPUT_VARIABLE-no-arg-result.txt diff --git a/Tests/RunCMake/cmake_path/CONCAT-OUTPUT_VARIABLE-invalid-arg-result.txt b/Tests/RunCMake/cmake_path/APPEND_STRING-wrong-path-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/cmake_path/CONCAT-OUTPUT_VARIABLE-invalid-arg-result.txt +++ b/Tests/RunCMake/cmake_path/APPEND_STRING-wrong-path-result.txt diff --git a/Tests/RunCMake/cmake_path/CONCAT.cmake b/Tests/RunCMake/cmake_path/APPEND_STRING.cmake index 62b5eb0..ea5f2dd 100644 --- a/Tests/RunCMake/cmake_path/CONCAT.cmake +++ b/Tests/RunCMake/cmake_path/APPEND_STRING.cmake @@ -3,13 +3,13 @@ include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") unset (errors) set (path "/a/b") -cmake_path (CONCAT path "cd") +cmake_path (APPEND_STRING path "cd") if (NOT path STREQUAL "/a/bcd") list (APPEND errors "'${path}' instead of 'a/bcd'") endif() set (path "/a/b") -cmake_path (CONCAT path "cd" "ef" OUTPUT_VARIABLE output) +cmake_path (APPEND_STRING path "cd" "ef" OUTPUT_VARIABLE output) if (NOT path STREQUAL "/a/b") list (APPEND errors "input changed unexpectedly") endif() @@ -17,4 +17,4 @@ if (NOT output STREQUAL "/a/bcdef") list (APPEND errors "'${output}' instead of 'a/bcdef'") endif() -check_errors (CONCAT ${errors}) +check_errors (APPEND_STRING ${errors}) diff --git a/Tests/RunCMake/cmake_path/CMAKE_PATH-OUTPUT_VARIABLE-no-arg-result.txt b/Tests/RunCMake/cmake_path/CMAKE_PATH-OUTPUT_VARIABLE-no-arg-result.txt deleted file mode 100644 index d00491f..0000000 --- a/Tests/RunCMake/cmake_path/CMAKE_PATH-OUTPUT_VARIABLE-no-arg-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/cmake_path/CMAKE_PATH-invalid-output-result.txt b/Tests/RunCMake/cmake_path/CMAKE_PATH-invalid-output-result.txt deleted file mode 100644 index d00491f..0000000 --- a/Tests/RunCMake/cmake_path/CMAKE_PATH-invalid-output-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/cmake_path/CMAKE_PATH-missing-output-result.txt b/Tests/RunCMake/cmake_path/CMAKE_PATH-missing-output-result.txt deleted file mode 100644 index d00491f..0000000 --- a/Tests/RunCMake/cmake_path/CMAKE_PATH-missing-output-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/cmake_path/CMAKE_PATH-unexpected-arg-result.txt b/Tests/RunCMake/cmake_path/CMAKE_PATH-unexpected-arg-result.txt deleted file mode 100644 index d00491f..0000000 --- a/Tests/RunCMake/cmake_path/CMAKE_PATH-unexpected-arg-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/cmake_path/CMAKE_PATH-wrong-path-result.txt b/Tests/RunCMake/cmake_path/CMAKE_PATH-wrong-path-result.txt deleted file mode 100644 index d00491f..0000000 --- a/Tests/RunCMake/cmake_path/CMAKE_PATH-wrong-path-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/cmake_path/COMPARE.cmake b/Tests/RunCMake/cmake_path/COMPARE.cmake index bc6b9b4..ecf7c82 100644 --- a/Tests/RunCMake/cmake_path/COMPARE.cmake +++ b/Tests/RunCMake/cmake_path/COMPARE.cmake @@ -2,19 +2,19 @@ include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") unset (errors) -set (path "a///b/c") -cmake_path(COMPARE path EQUAL "a/b/c" output) +set(path "a///b/c") +cmake_path(COMPARE "${path}" EQUAL "a/b/c" output) if (NOT output) list (APPEND errors "'${path}' not equal to 'a/b/c'") endif() set (path "a/b/d/../c") -cmake_path(COMPARE path NOT_EQUAL "a/b/c" output) +cmake_path(COMPARE "${path}" NOT_EQUAL "a/b/c" output) if (NOT output) list (APPEND errors "'${path}' equal to 'a/b/c'") endif() cmake_path(NORMAL_PATH path) -cmake_path(COMPARE path EQUAL "a/b/c" output) +cmake_path(COMPARE "${path}" EQUAL "a/b/c" output) if (NOT output) list (APPEND errors "'${path}' not equal to 'a/b/c'") endif() diff --git a/Tests/RunCMake/cmake_path/PROXIMATE_PATH.cmake b/Tests/RunCMake/cmake_path/PROXIMATE_PATH.cmake deleted file mode 100644 index ad23377..0000000 --- a/Tests/RunCMake/cmake_path/PROXIMATE_PATH.cmake +++ /dev/null @@ -1,41 +0,0 @@ - -include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") -unset (errors) - -if (WIN32) - set (path "c:/a/d") - cmake_path(PROXIMATE_PATH path BASE_DIRECTORY "e/d/c") - if (NOT path STREQUAL "c:/a/d") - list (APPEND errors "'${path}' instead of 'c:/a/d'") - endif() -else() - set (path "/a/d") - cmake_path(PROXIMATE_PATH path BASE_DIRECTORY "e/d/c") - if (NOT path STREQUAL "/a/d") - list (APPEND errors "'${path}' instead of '/a/d'") - endif() -endif() - -set (path "/a/d") -cmake_path(PROXIMATE_PATH path BASE_DIRECTORY "/a/b/c" OUTPUT_VARIABLE output) -if (NOT path STREQUAL "/a/d") - list (APPEND errors "input changed unexpectedly") -endif() -if (NOT output STREQUAL "../../d") - list (APPEND errors "'${output}' instead of '../../d'") -endif() - -set (path "${CMAKE_CURRENT_SOURCE_DIR}/a/d") -cmake_path(PROXIMATE_PATH path) -if (NOT path STREQUAL "a/d") - list (APPEND errors "'${path}' instead of 'a/d'") -endif() - -set (path "a/b/c") -cmake_path(PROXIMATE_PATH path) -if (NOT path STREQUAL "a/b/c") - list (APPEND errors "'${path}' instead of 'a/b/c'") -endif() - - -check_errors (PROXIMATE_PATH ${errors}) diff --git a/Tests/RunCMake/cmake_path/RunCMakeTest.cmake b/Tests/RunCMake/cmake_path/RunCMakeTest.cmake index ca9cba6..4edfb1a 100644 --- a/Tests/RunCMake/cmake_path/RunCMakeTest.cmake +++ b/Tests/RunCMake/cmake_path/RunCMakeTest.cmake @@ -11,14 +11,9 @@ foreach (subcommand IN ITEMS ROOT_NAME ROOT_DIRECTORY ROOT_PATH FILENAME EXTENSI run_cmake_command (GET-${subcommand}-wrong-path "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=GET wrong_path ${subcommand} output" -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") endforeach() -### COMPARE sub-command -foreach (subcommand IN ITEMS EQUAL NOT_EQUAL) - run_cmake_command (COMPARE-${subcommand}-wrong-path "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=COMPARE wrong_path ${subcommand} path2 output" -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") -endforeach() - -foreach (command IN ITEMS CONCAT REMOVE_FILENAME REPLACE_FILENAME +foreach (command IN ITEMS APPEND_STRING REMOVE_FILENAME REPLACE_FILENAME REMOVE_EXTENSION REPLACE_EXTENSION NORMAL_PATH - RELATIVE_PATH PROXIMATE_PATH ABSOLUTE_PATH) + RELATIVE_PATH ABSOLUTE_PATH) run_cmake_command (${command}-wrong-path "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=${command} wrong_path" -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") endforeach() @@ -55,7 +50,7 @@ foreach (subcommand IN ITEMS EQUAL NOT_EQUAL) run_cmake_command (COMPARE-${subcommand}-missing-output "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=COMPARE path ${subcommand} path2" -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") endforeach() -foreach (command IN ITEMS CMAKE_PATH NATIVE_PATH +foreach (command IN ITEMS SET NATIVE_PATH HAS_ROOT_NAME HAS_ROOT_DIRECTORY HAS_ROOT_PATH HAS_FILENAME HAS_EXTENSION HAS_STEM HAS_RELATIVE_PATH HAS_PARENT_PATH @@ -72,9 +67,9 @@ endforeach() ## OUTPUT_VARIABLE without argument set (RunCMake-stderr-file "OUTPUT_VARIABLE-no-arg-stderr.txt") -foreach (command IN ITEMS APPEND CONCAT REMOVE_FILENAME REPLACE_FILENAME +foreach (command IN ITEMS APPEND APPEND_STRING REMOVE_FILENAME REPLACE_FILENAME REMOVE_EXTENSION REPLACE_EXTENSION NORMAL_PATH - RELATIVE_PATH PROXIMATE_PATH ABSOLUTE_PATH) + RELATIVE_PATH ABSOLUTE_PATH) run_cmake_command (${command}-OUTPUT_VARIABLE-no-arg "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=${command} path OUTPUT_VARIABLE" -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") endforeach() @@ -98,7 +93,7 @@ foreach (subcommand IN ITEMS EQUAL NOT_EQUAL) run_cmake_command (COMPARE-${subcommand}-invalid-output "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=COMPARE path ${subcommand} path2" -DCHECK_INVALID_OUTPUT=ON -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") endforeach() -foreach (command IN ITEMS CMAKE_PATH NATIVE_PATH +foreach (command IN ITEMS NATIVE_PATH HAS_ROOT_NAME HAS_ROOT_DIRECTORY HAS_ROOT_PATH HAS_FILENAME HAS_EXTENSION HAS_STEM HAS_RELATIVE_PATH HAS_PARENT_PATH @@ -111,9 +106,9 @@ foreach (command IN ITEMS CMAKE_PATH NATIVE_PATH run_cmake_command (${command}-invalid-output "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=${command} path ${extra_args}" -DCHECK_INVALID_OUTPUT=ON -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") endforeach() -foreach (command IN ITEMS APPEND CONCAT REMOVE_FILENAME REPLACE_FILENAME +foreach (command IN ITEMS APPEND APPEND_STRING REMOVE_FILENAME REPLACE_FILENAME REMOVE_EXTENSION REPLACE_EXTENSION NORMAL_PATH - RELATIVE_PATH PROXIMATE_PATH ABSOLUTE_PATH) + RELATIVE_PATH ABSOLUTE_PATH) run_cmake_command (${command}-OUTPUT_VARIABLE-invalid-arg "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=${command} path OUTPUT_VARIABLE" -DCHECK_INVALID_OUTPUT=ON -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") endforeach() @@ -139,7 +134,7 @@ endforeach() foreach (command IN ITEMS REMOVE_FILENAME REPLACE_FILENAME REMOVE_EXTENSION REPLACE_EXTENSION NORMAL_PATH - RELATIVE_PATH PROXIMATE_PATH ABSOLUTE_PATH) + RELATIVE_PATH ABSOLUTE_PATH) if (command STREQUAL "REPLACE_FILENAME" OR command STREQUAL "REPLACE_EXTENSION") set (extra_args input) else() @@ -148,7 +143,7 @@ foreach (command IN ITEMS REMOVE_FILENAME REPLACE_FILENAME run_cmake_command (${command}-unexpected-arg "${CMAKE_COMMAND}" "-DCMAKE_PATH_ARGUMENTS=${command} path ${extra_args} unexpected" -P "${RunCMake_SOURCE_DIR}/call-cmake_path.cmake") endforeach() -foreach (command IN ITEMS CMAKE_PATH NATIVE_PATH +foreach (command IN ITEMS SET NATIVE_PATH HAS_ROOT_NAME HAS_ROOT_DIRECTORY HAS_ROOT_PATH HAS_FILENAME HAS_EXTENSION HAS_STEM HAS_RELATIVE_PATH HAS_PARENT_PATH @@ -170,17 +165,16 @@ run_cmake(COMPARE-wrong-operator) set (RunCMake_TEST_OPTIONS "-DRunCMake_SOURCE_DIR=${RunCMake_SOURCE_DIR}") run_cmake(GET) +run_cmake(SET) run_cmake(APPEND) -run_cmake(CONCAT) +run_cmake(APPEND_STRING) run_cmake(REMOVE_FILENAME) run_cmake(REPLACE_FILENAME) run_cmake(REMOVE_EXTENSION) run_cmake(REPLACE_EXTENSION) run_cmake(NORMAL_PATH) run_cmake(RELATIVE_PATH) -run_cmake(PROXIMATE_PATH) run_cmake(ABSOLUTE_PATH) -run_cmake(CMAKE_PATH) run_cmake(NATIVE_PATH) run_cmake(CONVERT) run_cmake(COMPARE) diff --git a/Tests/RunCMake/cmake_path/COMPARE-NOT_EQUAL-wrong-path-result.txt b/Tests/RunCMake/cmake_path/SET-missing-output-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/cmake_path/COMPARE-NOT_EQUAL-wrong-path-result.txt +++ b/Tests/RunCMake/cmake_path/SET-missing-output-result.txt diff --git a/Tests/RunCMake/cmake_path/COMPARE-EQUAL-wrong-path-result.txt b/Tests/RunCMake/cmake_path/SET-unexpected-arg-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/cmake_path/COMPARE-EQUAL-wrong-path-result.txt +++ b/Tests/RunCMake/cmake_path/SET-unexpected-arg-result.txt diff --git a/Tests/RunCMake/cmake_path/CMAKE_PATH.cmake b/Tests/RunCMake/cmake_path/SET.cmake index b9320f3..445783e 100644 --- a/Tests/RunCMake/cmake_path/CMAKE_PATH.cmake +++ b/Tests/RunCMake/cmake_path/SET.cmake @@ -2,42 +2,42 @@ include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") unset (errors) -cmake_path(CMAKE_PATH path "/x/y/z/../../a/d") +cmake_path(SET path "/x/y/z/../../a/d") if (NOT path STREQUAL "/x/y/z/../../a/d") list (APPEND errors "'${path}' instead of '/x/y/z/../../a/d'") endif() -cmake_path(CMAKE_PATH path NORMALIZE "/x/y/z/../../a/d") +cmake_path(SET path NORMALIZE "/x/y/z/../../a/d") if (NOT path STREQUAL "/x/a/d") list (APPEND errors "'${path}' instead of '/x/a/d'") endif() if (WIN32) - cmake_path(CMAKE_PATH path "/x\\y/z\\..\\../a/d") + cmake_path(SET path "/x\\y/z\\..\\../a/d") if (NOT path STREQUAL "/x/y/z/../../a/d") list (APPEND errors "'${path}' instead of '/x/y/z/../../a/d'") endif() - cmake_path(CMAKE_PATH path NORMALIZE "/x\\y/z\\..\\../a/d") + cmake_path(SET path NORMALIZE "/x\\y/z\\..\\../a/d") if (NOT path STREQUAL "/x/a/d") list (APPEND errors "'${path}' instead of '/x/a/d'") endif() - cmake_path(CMAKE_PATH path "//?/c:/x\\y/z\\..\\../a/d") + cmake_path(SET path "//?/c:/x\\y/z\\..\\../a/d") if (NOT path STREQUAL "c:/x/y/z/../../a/d") list (APPEND errors "'${path}' instead of 'c:/x/y/z/../../a/d'") endif() - cmake_path(CMAKE_PATH path NORMALIZE "//?/c:/x\\y/z\\..\\../a/d") + cmake_path(SET path NORMALIZE "//?/c:/x\\y/z\\..\\../a/d") if (NOT path STREQUAL "c:/x/a/d") list (APPEND errors "'${path}' instead of 'c:/x/a/d'") endif() - cmake_path(CMAKE_PATH path "\\\\?\\UNC/host/x\\y/z\\..\\../a/d") + cmake_path(SET path "\\\\?\\UNC/host/x\\y/z\\..\\../a/d") if (NOT path STREQUAL "//host/x/y/z/../../a/d") list (APPEND errors "'${path}' instead of '//host/x/y/z/../../a/d'") endif() - cmake_path(CMAKE_PATH path NORMALIZE "\\\\?\\UNC\\host/x\\y/z\\..\\../a/d") + cmake_path(SET path NORMALIZE "\\\\?\\UNC\\host/x\\y/z\\..\\../a/d") if (NOT path STREQUAL "//host/x/a/d") list (APPEND errors "'${path}' instead of '//host/x/a/d'") endif() endif() -check_errors (CMAKE_PATH ${errors}) +check_errors (SET ${errors}) |