summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/cmake_path/REPLACE_EXTENSION.cmake
blob: 45c15750d45c8377c331d70b534c1d527e0ac110 (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

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

set (path "a/b/c.e.f")
cmake_path (REPLACE_EXTENSION path ".x")
if (NOT path STREQUAL "a/b/c.x")
  list (APPEND errors "'${path}' instead of 'a/b/c.x'")
endif()
cmake_path (REPLACE_EXTENSION path ".y")
if (NOT path STREQUAL "a/b/c.y")
  list (APPEND errors "'${path}' instead of 'a/b/c.y'")
endif()
cmake_path (REPLACE_EXTENSION path "")
if (NOT path STREQUAL "a/b/c")
  list (APPEND errors "'${path}' instead of 'a/b/c'")
endif()

set (path "a/b/c.e.f")
cmake_path (REPLACE_EXTENSION path ".x" LAST_ONLY)
if (NOT path STREQUAL "a/b/c.e.x")
  list (APPEND errors "'${path}' instead of 'a/b/c.e.x'")
endif()
cmake_path (REPLACE_EXTENSION path ".y" LAST_ONLY)
if (NOT path STREQUAL "a/b/c.e.y")
  list (APPEND errors "'${path}' instead of 'a/b/c.e.y'")
endif()
cmake_path (REPLACE_EXTENSION path "" LAST_ONLY)
if (NOT path STREQUAL "a/b/c.e")
  list (APPEND errors "'${path}' instead of 'a/b/c.e'")
endif()

set (path "/a/.b")
cmake_path (REPLACE_EXTENSION path ".x")
if (NOT path STREQUAL "/a/.b.x")
  list (APPEND errors "'${path}' instead of '/a/.b.x'")
endif()
cmake_path (REPLACE_EXTENSION path ".x" LAST_ONLY)
if (NOT path STREQUAL "/a/.b.x")
  list (APPEND errors "'${path}' instead of '/a/.b.x'")
endif()

set (path "/a/b")
cmake_path (REPLACE_EXTENSION path ".x")
if (NOT path STREQUAL "/a/b.x")
  list (APPEND errors "'${path}' instead of '/a/b.x'")
endif()

set (path "/a/b/")
cmake_path (REPLACE_EXTENSION path ".x" OUTPUT_VARIABLE output)
if (NOT path STREQUAL "/a/b/")
  list (APPEND errors "input changed unexpectedly")
endif()
if (NOT output STREQUAL "/a/b/.x")
  list (APPEND errors "'${output}' instead of '/a/b/.x'")
endif()

check_errors (REPLACE_EXTENSION ${errors})