diff options
author | Jon Chronopoulos <patches@crondog.com> | 2019-08-26 04:21:12 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-08-30 14:37:30 (GMT) |
commit | e6c9a8bac3a2f3103ee79058e92dadd2d30c8ac5 (patch) | |
tree | c8d3145e78215886dc052210401b8fecc078d509 /Source/cmcmd.cxx | |
parent | 2a1be178de5f12d55ec486609f4512e6b2b9d168 (diff) | |
download | CMake-e6c9a8bac3a2f3103ee79058e92dadd2d30c8ac5.zip CMake-e6c9a8bac3a2f3103ee79058e92dadd2d30c8ac5.tar.gz CMake-e6c9a8bac3a2f3103ee79058e92dadd2d30c8ac5.tar.bz2 |
cmake: Teach -E remove_directory to remove directory symlinks
If the argument to `remove_directory` is a symlink to a directory,
remove the symlink instead.
Issue: #19533
Diffstat (limited to 'Source/cmcmd.cxx')
-rw-r--r-- | Source/cmcmd.cxx | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 0832e2f..fbbd47c 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -676,10 +676,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; |