summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/try_compile/CleanupNoFollowSymlink.cmake
blob: dea0f61d957b5a8bc891b56347e7109f6987885e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
enable_language(C)

set(out "${CMAKE_CURRENT_BINARY_DIR}/folder")
set(link_folder "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CMakeTmp")
set(link_dir "${link_folder}/link_dir")
file(MAKE_DIRECTORY "${out}")
file(MAKE_DIRECTORY "${link_folder}")
file(WRITE ${out}/empty_file "")
file(CREATE_LINK ${out} ${link_dir} SYMBOLIC)

try_compile(res ${CMAKE_CURRENT_BINARY_DIR}
  SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src.c)

if(EXISTS ${link_dir})
  message(FATAL_ERROR "did not remove ${link_dir}")
endif()
if(NOT EXISTS ${out})
  message(FATAL_ERROR "should not have removed ${out}/dir")
endif()

file(REMOVE_RECURSE "${out}")