diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2020-11-09 15:16:07 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2020-11-11 22:43:51 (GMT) |
commit | ed21ad181e0c3fd9fc1a8094fc2f8b8daafefc6d (patch) | |
tree | 58ae66a7739e5f86240c109b145d5e8d019b9445 /Tests/RunCMake/cmake_path | |
parent | 8b9497e3e52cfa23a1ba64f08db7f4ef9b602382 (diff) | |
download | CMake-ed21ad181e0c3fd9fc1a8094fc2f8b8daafefc6d.zip CMake-ed21ad181e0c3fd9fc1a8094fc2f8b8daafefc6d.tar.gz CMake-ed21ad181e0c3fd9fc1a8094fc2f8b8daafefc6d.tar.bz2 |
cmake_path: various enhancements to subcommands/keywords
This change address partly the remarks done in issue #21385
Diffstat (limited to 'Tests/RunCMake/cmake_path')
15 files changed, 28 insertions, 80 deletions
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}) |