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

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

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

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

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

check_errors (REPLACE_FILENAME ${errors})