summaryrefslogtreecommitdiff
path: root/Tests/RunCMake/GenEx-PATH/CMAKE_PATH.cmake.in
blob: 29ebf165b1b65af1b2dde1ce36ff8ffa54322316 (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95

include ("${RunCMake_SOURCE_DIR}/check_errors.cmake")
unset (errors)


cmake_path(SET reference "/x/y/z/../../a/d")
set(output "$<PATH:CMAKE_PATH,/x/y/z/../../a/d>")
if (NOT output STREQUAL reference)
  list (APPEND errors "'${output}' instead of '${reference}'")
endif()
cmake_path(SET reference NORMALIZE "/x/y/z/../../a/d")
set(output "$<PATH:CMAKE_PATH,NORMALIZE,/x/y/z/../../a/d>")
if (NOT output STREQUAL reference)
  list (APPEND errors "'${output}' instead of '${reference}'")
endif()

if (WIN32)
  cmake_path(SET reference "/x\\y/z\\..\\../a/d")
  set(output "$<PATH:CMAKE_PATH,/x\y/z\..\../a/d>")
  if (NOT output STREQUAL reference)
    list (APPEND errors "'${output}' instead of '${reference}'")
  endif()
  cmake_path(SET reference NORMALIZE "/x\\y/z\\..\\../a/d")
  set(output "$<PATH:CMAKE_PATH,NORMALIZE,/x\y/z\..\../a/d>")
  if (NOT output STREQUAL reference)
    list (APPEND errors "'${output}' instead of '${reference}'")
  endif()

  cmake_path(SET reference "//?/c:/x\\y/z\\..\\../a/d")
  set(output "$<PATH:CMAKE_PATH,//?/c:/x\y/z\..\../a/d>")
  if (NOT output STREQUAL reference)
    list (APPEND errors "'${output}' instead of '${reference}'")
  endif()
  cmake_path(SET reference NORMALIZE "//?/c:/x\\y/z\\..\\../a/d")
  set(output "$<PATH:CMAKE_PATH,NORMALIZE,//?/c:/x\y/z\..\../a/d>")
  if (NOT output STREQUAL reference)
    list (APPEND errors "'${output}' instead of '${reference}'")
  endif()

  cmake_path(SET reference "\\\\?\\UNC/host/x\\y/z\\..\\../a/d")
  set(output "$<PATH:CMAKE_PATH,\\?\UNC/host/x\y/z\..\../a/d>")
  if (NOT output STREQUAL reference)
    list (APPEND errors "'${output}' instead of '${reference}'")
  endif()
  cmake_path(SET reference NORMALIZE "\\\\?\\UNC\\host/x\\y/z\\..\\../a/d")
  set(output "$<PATH:CMAKE_PATH,NORMALIZE,\\?\UNC/host/x\y/z\..\../a/d>")
  if (NOT output STREQUAL reference)
    list (APPEND errors "'${output}' instead of '${reference}'")
  endif()
endif()


######################################
## tests with list of paths
######################################
set(reference "/x/y/z/../../a/d;/x/y/z/../../b/e")
set(output "$<PATH:CMAKE_PATH,/x/y/z/../../a/d;/x/y/z/../../b/e>")
if (NOT output STREQUAL reference)
  list (APPEND errors "'${output}' instead of '${reference}'")
endif()

unset(reference)
foreach(path IN ITEMS "/x/y/z/../../a/d" "/x/y/z/../../b/e")
  cmake_path(SET result NORMALIZE "${path}")
  list(APPEND reference "${result}")
endforeach()
set(output "$<PATH:CMAKE_PATH,NORMALIZE,/x/y/z/../../a/d;/x/y/z/../../b/e>")
if (NOT output STREQUAL reference)
  list (APPEND errors "'${output}' instead of '${reference}'")
endif()

if (WIN32)
  unset(reference)
  foreach(path IN ITEMS "/x\\y/z\\..\\../a/d" "/x\\y/z\\..\\../b/e")
    cmake_path(SET result "${path}")
    list(APPEND reference "${result}")
  endforeach()
  set(output "$<PATH:CMAKE_PATH,/x\y/z\..\../a/d;/x\y/z\..\../b/e>")
  if (NOT output STREQUAL reference)
    list (APPEND errors "'${output}' instead of '${reference}'")
  endif()

  unset(reference)
  foreach(path IN ITEMS "/x\\y/z\\..\\../a/d" "/x\\y/z\\..\\../b/e")
    cmake_path(SET result NORMALIZE "${path}")
    list(APPEND reference "${result}")
  endforeach()
  set(output "$<PATH:CMAKE_PATH,NORMALIZE,/x\y/z\..\../a/d;/x\y/z\..\../b/e>")
  if (NOT output STREQUAL reference)
    list (APPEND errors "'${output}' instead of '${reference}'")
  endif()
endif()


check_errors("PATH:CMAKE_PATH" ${errors})