blob: 463bc471bccc003c33f5735493fc12287d063add (
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
|
include ("${RunCMake_SOURCE_DIR}/check_errors.cmake")
unset (errors)
###############################################
## First test with a path defining all elements
###############################################
if (WIN32)
set (path "C:/aa/bb/cc.ext1.ext2")
else()
set (path "/aa/bb/cc.ext1.ext2")
endif()
cmake_path(GET path ROOT_NAME output)
if (WIN32)
if (NOT output STREQUAL "C:")
list (APPEND errors "ROOT_NAME returns bad data: ${output}")
endif()
else()
if (NOT output STREQUAL "")
list (APPEND errors "ROOT_NAME returns bad data: ${output}")
endif()
endif()
cmake_path(GET path ROOT_DIRECTORY output)
if (NOT output STREQUAL "/")
list (APPEND errors "ROOT_DIRECTORY returns bad data: ${output}")
endif()
cmake_path(GET path ROOT_PATH output)
if (WIN32)
if (NOT output STREQUAL "C:/")
list (APPEND errors "ROOT_PATH returns bad data: ${output}")
endif()
else()
if (NOT output STREQUAL "/")
list (APPEND errors "ROOT_PATH returns bad data: ${output}")
endif()
endif()
cmake_path(GET path FILENAME output)
if (NOT output STREQUAL "cc.ext1.ext2")
list (APPEND errors "FILENAME returns bad data: ${output}")
endif()
cmake_path(GET path EXTENSION output)
if (NOT output STREQUAL ".ext1.ext2")
list (APPEND errors "EXTENSION returns bad data: ${output}")
endif()
cmake_path(GET path EXTENSION LAST_ONLY output)
if (NOT output STREQUAL ".ext2")
list (APPEND errors "EXTENSION LAST_ONLY returns bad data: ${output}")
endif()
cmake_path(GET path STEM output)
if (NOT output STREQUAL "cc")
list (APPEND errors "STEM returns bad data: ${output}")
endif()
cmake_path(GET path STEM LAST_ONLY output)
if (NOT output STREQUAL "cc.ext1")
list (APPEND errors "STEM LAST_ONLY returns bad data: ${output}")
endif()
cmake_path(GET path RELATIVE_PART output)
if (NOT output STREQUAL "aa/bb/cc.ext1.ext2")
list (APPEND errors "RELATIVE_PART returns bad data: ${output}")
endif()
cmake_path(GET path PARENT_PATH output)
if (WIN32)
if (NOT output STREQUAL "C:/aa/bb")
list (APPEND errors "PARENT_PATH returns bad data: ${output}")
endif()
else()
if (NOT output STREQUAL "/aa/bb")
list (APPEND errors "PARENT_PATH returns bad data: ${output}")
endif()
endif()
######################################
## second, tests with missing elements
######################################
set (path "aa/bb/")
cmake_path(GET path ROOT_NAME output)
if (NOT output STREQUAL "")
list (APPEND errors "ROOT_NAME returns bad data: ${output}")
endif()
cmake_path(GET path ROOT_DIRECTORY output)
if (NOT output STREQUAL "")
list (APPEND errors "ROOT_DIRECTORY returns bad data: ${output}")
endif()
cmake_path(GET path ROOT_PATH output)
if (NOT output STREQUAL "")
list (APPEND errors "ROOT_PATH returns bad data: ${output}")
endif()
cmake_path(GET path FILENAME output)
if (NOT output STREQUAL "")
list (APPEND errors "FILENAME returns bad data: ${output}")
endif()
cmake_path(GET path EXTENSION output)
if (NOT output STREQUAL "")
list (APPEND errors "EXTENSION returns bad data: ${output}")
endif()
cmake_path(GET path STEM output)
if (NOT output STREQUAL "")
list (APPEND errors "STEM returns bad data: ${output}")
endif()
cmake_path(GET path RELATIVE_PART output)
if (NOT output STREQUAL path)
list (APPEND errors "RELATIVE_PART returns bad data: ${output}")
endif()
cmake_path(GET path PARENT_PATH output)
if (NOT output STREQUAL "aa/bb")
list (APPEND errors "PARENT_PATH returns bad data: ${output}")
endif()
##################################
set (path "/aa/bb/")
cmake_path(GET path ROOT_NAME output)
if (NOT output STREQUAL "")
list (APPEND errors "ROOT_NAME returns bad data: ${output}")
endif()
cmake_path(GET path ROOT_DIRECTORY output)
if (NOT output STREQUAL "/")
list (APPEND errors "ROOT_DIRECTORY returns bad data: ${output}")
endif()
cmake_path(GET path ROOT_PATH output)
if (NOT output STREQUAL "/")
list (APPEND errors "ROOT_PATH returns bad data: ${output}")
endif()
###################################
set (path "/")
cmake_path(GET path ROOT_NAME output)
if (NOT output STREQUAL "")
list (APPEND errors "ROOT_NAME returns bad data: ${output}")
endif()
cmake_path(GET path ROOT_DIRECTORY output)
if (NOT output STREQUAL "/")
list (APPEND errors "ROOT_DIRECTORY returns bad data: ${output}")
endif()
cmake_path(GET path ROOT_PATH output)
if (NOT output STREQUAL "/")
list (APPEND errors "ROOT_PATH returns bad data: ${output}")
endif()
cmake_path(GET path FILENAME output)
if (NOT output STREQUAL "")
list (APPEND errors "FILENAME returns bad data: ${output}")
endif()
cmake_path(GET path EXTENSION output)
if (NOT output STREQUAL "")
list (APPEND errors "EXTENSION returns bad data: ${output}")
endif()
cmake_path(GET path STEM output)
if (NOT output STREQUAL "")
list (APPEND errors "STEM returns bad data: ${output}")
endif()
cmake_path(GET path RELATIVE_PART output)
if (NOT output STREQUAL "")
list (APPEND errors "RELATIVE_PART returns bad data: ${output}")
endif()
cmake_path(GET path PARENT_PATH output)
if (NOT output STREQUAL "/")
list (APPEND errors "PARENT_PATH returns bad data: ${output}")
endif()
###################################
set (path ".file")
cmake_path(GET path FILENAME output)
if (NOT output STREQUAL ".file")
list (APPEND errors "FILENAME returns bad data: ${output}")
endif()
cmake_path(GET path EXTENSION output)
if (NOT output STREQUAL "")
list (APPEND errors "EXTENSION returns bad data: ${output}")
endif()
cmake_path(GET path STEM output)
if (NOT output STREQUAL ".file")
list (APPEND errors "STEM returns bad data: ${output}")
endif()
###################################
set (path ".file.ext")
cmake_path(GET path FILENAME output)
if (NOT output STREQUAL ".file.ext")
list (APPEND errors "FILENAME returns bad data: ${output}")
endif()
cmake_path(GET path EXTENSION output)
if (NOT output STREQUAL ".ext")
list (APPEND errors "EXTENSION returns bad data: ${output}")
endif()
cmake_path(GET path EXTENSION LAST_ONLY output)
if (NOT output STREQUAL ".ext")
list (APPEND errors "EXTENSION returns bad data: ${output}")
endif()
cmake_path(GET path STEM output)
if (NOT output STREQUAL ".file")
list (APPEND errors "STEM returns bad data: ${output}")
endif()
###################################
set (path ".file.ext1.ext2")
cmake_path(GET path FILENAME output)
if (NOT output STREQUAL ".file.ext1.ext2")
list (APPEND errors "FILENAME returns bad data: ${output}")
endif()
cmake_path(GET path EXTENSION output)
if (NOT output STREQUAL ".ext1.ext2")
list (APPEND errors "EXTENSION returns bad data: ${output}")
endif()
cmake_path(GET path EXTENSION LAST_ONLY output)
if (NOT output STREQUAL ".ext2")
list (APPEND errors "EXTENSION returns bad data: ${output}")
endif()
cmake_path(GET path STEM output)
if (NOT output STREQUAL ".file")
list (APPEND errors "STEM returns bad data: ${output}")
endif()
check_errors (GET ${errors})
|