blob: 2179911f24339a8b13f80820cd27c0ccda8c4c5b (
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
|
if(UNIX)
# file1 => file2 => file3 (real)
set(bindir ${CMAKE_CURRENT_BINARY_DIR})
file(WRITE ${bindir}/file3 "test file")
find_program(LN NAMES "ln")
if(LN)
# Create symlinks using "ln -s"
if(NOT EXISTS ${bindir}/file2)
execute_process(COMMAND ${LN} "-s" "${bindir}/file3" "${bindir}/file2")
endif()
if(NOT EXISTS ${bindir}/file1)
execute_process(COMMAND ${LN} "-s" "${bindir}/file2" "${bindir}/file1")
endif()
get_filename_component(file1 ${bindir}/file1 ABSOLUTE)
get_filename_component(file2 ${bindir}/file2 ABSOLUTE)
get_filename_component(file3 ${bindir}/file3 ABSOLUTE)
if(NOT file3 STREQUAL "${bindir}/file3")
message(FATAL_ERROR "CMake fails resolving absolute file file3")
endif()
if(NOT file2 STREQUAL "${bindir}/file3")
message(FATAL_ERROR "CMake fails resolving simple symlink")
endif()
if(NOT file1 STREQUAL "${bindir}/file3")
message(FATAL_ERROR "CMake fails resolving double symlink")
endif()
# cleanup
file(REMOVE ${bindir}/file1)
file(REMOVE ${bindir}/file2)
file(REMOVE ${bindir}/file3)
if(EXISTS file1 OR EXISTS file2 OR EXISTS file3)
message(FATAL_ERROR "removal of file1, file2, or file3 failed")
endif()
endif(LN)
endif()
|