diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2009-01-29 16:57:42 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2009-01-29 16:57:42 (GMT) |
commit | 4b5cabed0e40b7642b515a33568f1701577bb050 (patch) | |
tree | 1bf5f06dbc50fbee636b803adff3d31bfe3391f6 /Tests/CMakeTests | |
parent | 9b0fe5738b28f343c0c56689ff2bcc6203b5fb27 (diff) | |
download | CMake-4b5cabed0e40b7642b515a33568f1701577bb050.zip CMake-4b5cabed0e40b7642b515a33568f1701577bb050.tar.gz CMake-4b5cabed0e40b7642b515a33568f1701577bb050.tar.bz2 |
ENH: add missing file
Diffstat (limited to 'Tests/CMakeTests')
-rw-r--r-- | Tests/CMakeTests/GetFilenameComponentSymlinksTest.cmake.in | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/Tests/CMakeTests/GetFilenameComponentSymlinksTest.cmake.in b/Tests/CMakeTests/GetFilenameComponentSymlinksTest.cmake.in new file mode 100644 index 0000000..2179911 --- /dev/null +++ b/Tests/CMakeTests/GetFilenameComponentSymlinksTest.cmake.in @@ -0,0 +1,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() |