summaryrefslogtreecommitdiffstats
path: root/Source/cmcmd.cxx
diff options
context:
space:
mode:
authorRobert Maynard <rmaynard@nvidia.com>2023-01-11 21:19:09 (GMT)
committerRobert Maynard <rmaynard@nvidia.com>2023-01-12 13:39:41 (GMT)
commitc1170b5602d609f6ccd2506e5db9916c74388187 (patch)
treeb4ce41ec8edaecdd0347cdfd63251ebee28efb8e /Source/cmcmd.cxx
parent51a0292d9cb24e13f6b600bc97d950ad4344cfa5 (diff)
downloadCMake-c1170b5602d609f6ccd2506e5db9916c74388187.zip
CMake-c1170b5602d609f6ccd2506e5db9916c74388187.tar.gz
CMake-c1170b5602d609f6ccd2506e5db9916c74388187.tar.bz2
cmake: Add -E copy_directory_if_different
Fixes #21584
Diffstat (limited to 'Source/cmcmd.cxx')
-rw-r--r--Source/cmcmd.cxx11
1 files changed, 8 insertions, 3 deletions
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index 4303f96..21d0cc9 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -110,6 +110,8 @@ void CMakeCommandUsage(std::string const& program)
"(either file or directory)\n"
<< " copy_directory <dir>... destination - copy content of <dir>... "
"directories to 'destination' directory\n"
+ << " copy_directory_if_different <dir>... destination - copy changed content of <dir>... "
+ "directories to 'destination' directory\n"
<< " copy_if_different <file>... destination - copy files if it has "
"changed\n"
<< " echo [<string>...] - displays arguments as text\n"
@@ -731,12 +733,15 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args,
return return_value;
}
- // Copy directory content
- if (args[1] == "copy_directory" && args.size() > 3) {
+ // Copy directory contents
+ if ((args[1] == "copy_directory" ||
+ args[1] == "copy_directory_if_different") &&
+ args.size() > 3) {
// If error occurs we want to continue copying next files.
bool return_value = false;
+ const bool copy_always = (args[1] == "copy_directory");
for (auto const& arg : cmMakeRange(args).advance(2).retreat(1)) {
- if (!cmSystemTools::CopyADirectory(arg, args.back())) {
+ if (!cmSystemTools::CopyADirectory(arg, args.back(), copy_always)) {
std::cerr << "Error copying directory from \"" << arg << "\" to \""
<< args.back() << "\".\n";
return_value = true;