diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2020-07-23 14:54:12 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2020-09-06 08:52:25 (GMT) |
commit | eb583b0a660ba68e8e3b5f820301fde333619283 (patch) | |
tree | d88a52fdc1af9843ee4adceb1a37c66148d48c2e /Tests/RunCMake/cmake_path/RELATIVE_PATH.cmake | |
parent | 212e953d352c2ca20cf6280492633d21fbacdbc9 (diff) | |
download | CMake-eb583b0a660ba68e8e3b5f820301fde333619283.zip CMake-eb583b0a660ba68e8e3b5f820301fde333619283.tar.gz CMake-eb583b0a660ba68e8e3b5f820301fde333619283.tar.bz2 |
cmake_path command: path management
Fixes: #19568, #20922
Diffstat (limited to 'Tests/RunCMake/cmake_path/RELATIVE_PATH.cmake')
-rw-r--r-- | Tests/RunCMake/cmake_path/RELATIVE_PATH.cmake | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/Tests/RunCMake/cmake_path/RELATIVE_PATH.cmake b/Tests/RunCMake/cmake_path/RELATIVE_PATH.cmake new file mode 100644 index 0000000..522a899 --- /dev/null +++ b/Tests/RunCMake/cmake_path/RELATIVE_PATH.cmake @@ -0,0 +1,76 @@ + +include ("${RunCMake_SOURCE_DIR}/check_errors.cmake") +unset (errors) + +set (path "/a//d") +cmake_path(RELATIVE_PATH path BASE_DIRECTORY "/a/b/c") +if (NOT path STREQUAL "../../d") + list (APPEND errors "'${path}' instead of '../../d'") +endif() + +set (path "/a//b///c") +cmake_path(RELATIVE_PATH path BASE_DIRECTORY "/a/d") +if (NOT path STREQUAL "../b/c") + list (APPEND errors "'${path}' instead of '../b/c'") +endif() + +set (path "a/b/c") +cmake_path(RELATIVE_PATH path BASE_DIRECTORY "a") +if (NOT path STREQUAL "b/c") + list (APPEND errors "'${path}' instead of 'b/c'") +endif() + +set (path "a/b/c") +cmake_path(RELATIVE_PATH path BASE_DIRECTORY "a/b/c/x/y") +if (NOT path STREQUAL "../..") + list (APPEND errors "'${path}' instead of '../..'") +endif() + +set (path "a/b/c") +cmake_path(RELATIVE_PATH path BASE_DIRECTORY "a/b/c") +if (NOT path STREQUAL ".") + list (APPEND errors "'${path}' instead of '.'") +endif() + +set (path "a/b") +cmake_path(RELATIVE_PATH path BASE_DIRECTORY "c/d") +if (NOT path STREQUAL "../../a/b") + list (APPEND errors "'${path}' instead of '../../a/b'") +endif() + +set (path "${CMAKE_CURRENT_SOURCE_DIR}/../../b") +cmake_path(RELATIVE_PATH path) +if (NOT path STREQUAL "../../b") + list (APPEND errors "'${path}' instead of '../../b'") +endif() + +set (path "${CMAKE_CURRENT_SOURCE_DIR}/../../b") +cmake_path(RELATIVE_PATH path OUTPUT_VARIABLE output) +if (NOT path STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/../../b") + list (APPEND errors "input changed unexpectedly") +endif() +if (NOT output STREQUAL "../../b") + list (APPEND errors "'${output}' instead of '../../b'") +endif() + +if (WIN32) + set (path "/a/d") + cmake_path(RELATIVE_PATH path BASE_DIRECTORY "e/d/c") + if (NOT path STREQUAL "/a/d") + list (APPEND errors "'${path}' instead of '/a/d'") + endif() + + set (path "c:/a/d") + cmake_path(RELATIVE_PATH path BASE_DIRECTORY "e/d/c") + if (NOT path STREQUAL "") + list (APPEND errors "'${path}' instead of ''") + endif() +elseif() + set (path "/a/d") + cmake_path(RELATIVE_PATH path BASE_DIRECTORY "e/d/c") + if (NOT path STREQUAL "") + list (APPEND errors "'${path}' instead of ''") + endif() +endif() + +check_errors (RELATIVE_PATH ${errors}) |