mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 05:40:54 -06:00
Merge topic 'remove_directory-symlink'
e6c9a8bac3 cmake: Teach -E remove_directory to remove directory symlinks
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3738
This commit is contained in:
@@ -673,10 +673,17 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args)
|
||||
// If an error occurs, we want to continue removing directories.
|
||||
bool return_value = false;
|
||||
for (auto const& arg : cmMakeRange(args).advance(2)) {
|
||||
if (cmSystemTools::FileIsDirectory(arg) &&
|
||||
!cmSystemTools::RemoveADirectory(arg)) {
|
||||
std::cerr << "Error removing directory \"" << arg << "\".\n";
|
||||
return_value = true;
|
||||
if (cmSystemTools::FileIsDirectory(arg)) {
|
||||
if (cmSystemTools::FileIsSymlink(arg)) {
|
||||
if (!cmSystemTools::RemoveFile(arg)) {
|
||||
std::cerr << "Error removing directory symlink \"" << arg
|
||||
<< "\".\n";
|
||||
return_value = true;
|
||||
}
|
||||
} else if (!cmSystemTools::RemoveADirectory(arg)) {
|
||||
std::cerr << "Error removing directory \"" << arg << "\".\n";
|
||||
return_value = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return return_value;
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
if(EXISTS ${out}/link_dir)
|
||||
set(RunCMake_TEST_FAILED "did not remove ${out}/link_dir")
|
||||
endif()
|
||||
if(NOT EXISTS ${out}/dir)
|
||||
set(RunCMake_TEST_FAILED "should not have removed ${out}/dir")
|
||||
endif()
|
||||
@@ -0,0 +1,6 @@
|
||||
if(NOT EXISTS ${outfile})
|
||||
set(RunCMake_TEST_FAILED "removed non-directory ${outfile}")
|
||||
endif()
|
||||
if(NOT EXISTS ${out}/link_file_for_test.txt)
|
||||
set(RunCMake_TEST_FAILED "removed non-directory symlink ${out}/link_file_for_test.txt")
|
||||
endif()
|
||||
@@ -348,6 +348,17 @@ run_cmake_command(E_make_directory-two-directories-and-file
|
||||
${CMAKE_COMMAND} -E make_directory ${out}/d1 ${out}/d2 ${outfile})
|
||||
run_cmake_command(E_remove_directory-two-directories-and-file
|
||||
${CMAKE_COMMAND} -E remove_directory ${out}/d1 ${out}/d2 ${outfile})
|
||||
|
||||
if(UNIX)
|
||||
file(MAKE_DIRECTORY ${out}/dir)
|
||||
file(CREATE_LINK ${out}/dir ${out}/link_dir SYMBOLIC)
|
||||
file(CREATE_LINK ${outfile} ${out}/link_file_for_test.txt SYMBOLIC)
|
||||
run_cmake_command(E_remove_directory-symlink-dir
|
||||
${CMAKE_COMMAND} -E remove_directory ${out}/link_dir)
|
||||
run_cmake_command(E_remove_directory-symlink-file
|
||||
${CMAKE_COMMAND} -E remove_directory ${out}/link_file_for_test.txt)
|
||||
endif()
|
||||
|
||||
unset(out)
|
||||
unset(outfile)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user