summaryrefslogtreecommitdiff
path: root/Tests/RunCMake/cmake_path/CONVERT.cmake
blob: b08bc26cf01176b5cebdcec91cf7a11a75d0c7b6 (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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110

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

cmake_path(CONVERT "/x/y/z/../../a/d" TO_CMAKE_PATH_LIST output)
if (NOT output STREQUAL "/x/y/z/../../a/d")
  list (APPEND errors "TO_CMAKE_PATH_LIST: '${output}' instead of '/x/y/z/../../a/d'")
endif()
cmake_path(CONVERT "/x/y/z/../../a/d" TO_CMAKE_PATH_LIST output NORMALIZE)
if (NOT output STREQUAL "/x/a/d")
  list (APPEND errors "TO_CMAKE_PATH_LIST: '${output}' instead of '/x/a/d'")
endif()

if (WIN32)
  cmake_path(CONVERT "/x\\y/z\\..\\../a/d" TO_CMAKE_PATH_LIST output)
  if (NOT output STREQUAL "/x/y/z/../../a/d")
    list (APPEND errors "TO_CMAKE_PATH_LIST: '${output}' instead of '/x/y/z/../../a/d'")
  endif()
  cmake_path(CONVERT "/x\\y/z\\..\\../a/d" TO_CMAKE_PATH_LIST output NORMALIZE)
  if (NOT output STREQUAL "/x/a/d")
    list (APPEND errors "TO_CMAKE_PATH_LIST: '${output}' instead of '/x/a/d'")
  endif()

  cmake_path(CONVERT "//?/c:/x\\y/z\\..\\../a/d" TO_CMAKE_PATH_LIST output)
  if (NOT output STREQUAL "c:/x/y/z/../../a/d")
    list (APPEND errors "TO_CMAKE_PATH_LIST: '${output}' instead of 'c:/x/y/z/../../a/d'")
  endif()
  cmake_path(CONVERT "//?/c:/x\\y/z\\..\\../a/d" TO_CMAKE_PATH_LIST output NORMALIZE)
  if (NOT output STREQUAL "c:/x/a/d")
    list (APPEND errors "TO_CMAKE_PATH_LIST: '${output}' instead of 'c:/x/a/d'")
  endif()

  cmake_path(CONVERT "//?/UNC/host/x\\y/z\\..\\../a/d" TO_CMAKE_PATH_LIST output)
  if (NOT output STREQUAL "//host/x/y/z/../../a/d")
    list (APPEND errors "TO_CMAKE_PATH_LIST: '${output}' instead of '//host/x/y/z/../../a/d'")
  endif()
  cmake_path(CONVERT "//?/UNC/host/x\\y/z\\..\\../a/d" TO_CMAKE_PATH_LIST output NORMALIZE)
  if (NOT output STREQUAL "//host/x/a/d")
    list (APPEND errors "TO_CMAKE_PATH_LIST: '${output}' instead of '//host/x/a/d'")
  endif()
endif()

if (WIN32)
  cmake_path(CONVERT "/x\\y/z/..\\../a\\d;c:\\a/b\\c/..\\d" TO_CMAKE_PATH_LIST output)
  if (NOT output STREQUAL "/x/y/z/../../a/d;c:/a/b/c/../d")
    list (APPEND errors "TO_CMAKE_PATH_LIST: '${output}' instead of '/x/y/z/../../a/d;c:/a/b/c/../d'")
  endif()
  cmake_path(CONVERT "/x\\y/z/..\\../a\\d;c:\\a/b\\c/..\\d" TO_CMAKE_PATH_LIST output NORMALIZE)
  if (NOT output STREQUAL "/x/a/d;c:/a/b/d")
    list (APPEND errors "TO_CMAKE_PATH_LIST: '${output}' instead of '/x/a/d;c:/a/b/d'")
  endif()
else()
  cmake_path(CONVERT "/x/y/z/../../a/d:/a/b/c/../d" TO_CMAKE_PATH_LIST output)
  if (NOT output STREQUAL "/x/y/z/../../a/d;/a/b/c/../d")
    list (APPEND errors "TO_CMAKE_PATH_LIST: '${outputh}' instead of '/x/y/z/../../a/d;/a/b/c/../d'")
  endif()
  cmake_path(CONVERT "/x/y/z/../../a/d:/a/b/c/../d" TO_CMAKE_PATH_LIST output NORMALIZE)
  if (NOT output STREQUAL "/x/a/d;/a/b/d")
    list (APPEND errors "TO_CMAKE_PATH_LIST: '${output}' instead of '/x/a/d;/a/b/d'")
  endif()
endif()


if (WIN32)
  cmake_path(CONVERT "c:/a//b\\c/..\\d" TO_NATIVE_PATH_LIST output)
  if (NOT output STREQUAL "c:\\a\\\\b\\c\\..\\d")
    list (APPEND errors "TO_NATIVE_PATH_LIST: '${output}' instead of 'c:\\a\\\\b\\c\\..\\d'")
  endif()
  cmake_path(CONVERT "c:/a//b\\c/..\\d" TO_NATIVE_PATH_LIST output NORMALIZE)
  if (NOT output STREQUAL "c:\\a\\b\\d")
    list (APPEND errors "TO_NATIVE_PATH_LIST: '${output}' instead of 'c:\\a\\b\\d'")
  endif()

  cmake_path(CONVERT "//host/a//b\\c/..\\d" TO_NATIVE_PATH_LIST output)
  if (NOT output STREQUAL "\\\\host\\a\\\\b\\c\\..\\d")
    list (APPEND errors "TO_NATIVE_PATH_LIST: '${output}' instead of '\\\\host\\a\\\\b\\c\\..\\d'")
  endif()
  cmake_path(CONVERT "//host/a//b\\c/..\\d" TO_NATIVE_PATH_LIST output NORMALIZE)
  if (NOT output STREQUAL "\\\\host\\a\\b\\d")
    list (APPEND errors "TO_NATIVE_PATH_LIST: '${output}' instead of '\\\\host\\a\\b\\d'")
  endif()
  cmake_path(CONVERT "//host/a//b\\c/..\\d;c:/a//b\\c/..\\d" TO_NATIVE_PATH_LIST output)
  if (NOT output STREQUAL "\\\\host\\a\\\\b\\c\\..\\d;c:\\a\\\\b\\c\\..\\d")
    list (APPEND errors "TO_NATIVE_PATH_LIST: '${output}' instead of '\\\\host\\a\\\\b\\c\\..\\d;c:\\a\\\\b\\c\\..\\d'")
  endif()
  cmake_path(CONVERT "//host/a//b\\c/..\\d;c:/a//b\\c/..\\d" TO_NATIVE_PATH_LIST output NORMALIZE)
  if (NOT output STREQUAL "\\\\host\\a\\b\\d;c:\\a\\b\\d")
    list (APPEND errors "TO_NATIVE_PATH_LIST: '${output}' instead of '\\\\host\\a\\b\\d;c:\\a\\b\\d'")
  endif()
else()
  cmake_path(CONVERT "/a//b/c/../d" TO_NATIVE_PATH_LIST output)
  if (NOT output STREQUAL "/a//b/c/../d")
    list (APPEND errors "TO_NATIVE_PATH_LIST: '${output}' instead of '/a//b/c/../d'")
  endif()
  cmake_path(CONVERT "/a//b/c/../d" TO_NATIVE_PATH_LIST output NORMALIZE)
  if (NOT output STREQUAL "/a/b/d")
    list (APPEND errors "TO_NATIVE_PATH_LIST: '${output}' instead of '/a/b/d'")
  endif()
  cmake_path(CONVERT "/x/y/z/../../a/d;/a/b/c/../d" TO_NATIVE_PATH_LIST output)
  if (NOT output STREQUAL "/x/y/z/../../a/d:/a/b/c/../d")
    list (APPEND errors "TO_NATIVE_PATH_LIST: '${output}' instead of '/x/y/z/../../a/d:/a/b/c/../d'")
  endif()
  cmake_path(CONVERT "/x/y/z/../../a/d;/a/b/c/../d" TO_NATIVE_PATH_LIST output NORMALIZE)
  if (NOT output STREQUAL "/x/a/d:/a/b/d")
    list (APPEND errors "TO_NATIVE_PATH_LIST: '${output}' instead of '/x/a/d:/a/b/d'")
  endif()
endif()


check_errors (CONVERT ${errors})