summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/cmake_path/PROXIMATE_PATH.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/RunCMake/cmake_path/PROXIMATE_PATH.cmake')
-rw-r--r--Tests/RunCMake/cmake_path/PROXIMATE_PATH.cmake41
1 files changed, 41 insertions, 0 deletions
diff --git a/Tests/RunCMake/cmake_path/PROXIMATE_PATH.cmake b/Tests/RunCMake/cmake_path/PROXIMATE_PATH.cmake
new file mode 100644
index 0000000..ad23377
--- /dev/null
+++ b/Tests/RunCMake/cmake_path/PROXIMATE_PATH.cmake
@@ -0,0 +1,41 @@
+
+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})