summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/cmake_path/PROXIMATE_PATH.cmake
blob: ad23377640f2754b809abc39f130aa64689be8bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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})