mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-04 12:49:36 -06:00
cmCoreTryCompile::CleanupFiles now removes symlinks instead of their contents.
Fixes: #17522
This commit is contained in:
@@ -1045,7 +1045,9 @@ void cmCoreTryCompile::CleanupFiles(std::string const& binDir)
|
||||
if (deletedFiles.insert(fileName).second) {
|
||||
std::string const fullPath =
|
||||
std::string(binDir).append("/").append(fileName);
|
||||
if (cmSystemTools::FileIsDirectory(fullPath)) {
|
||||
if (cmSystemTools::FileIsSymlink(fullPath)) {
|
||||
cmSystemTools::RemoveFile(fullPath);
|
||||
} else if (cmSystemTools::FileIsDirectory(fullPath)) {
|
||||
this->CleanupFiles(fullPath);
|
||||
cmSystemTools::RemoveADirectory(fullPath);
|
||||
} else {
|
||||
|
||||
21
Tests/RunCMake/try_compile/CleanupNoFollowSymlink.cmake
Normal file
21
Tests/RunCMake/try_compile/CleanupNoFollowSymlink.cmake
Normal file
@@ -0,0 +1,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}")
|
||||
@@ -94,3 +94,7 @@ if(RunCMake_GENERATOR MATCHES "Make|Ninja")
|
||||
unset(RunCMake_TEST_BINARY_DIR)
|
||||
unset(RunCMake_TEST_NO_CLEAN)
|
||||
endif()
|
||||
|
||||
if(UNIX)
|
||||
run_cmake(CleanupNoFollowSymlink)
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user