summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-03-25 14:24:41 -0400
committerBrad King <brad.king@kitware.com>2019-03-26 10:51:47 -0400
commitce180cf810841ccc813ba7becc8043dd426fc966 (patch)
tree0ad65ae78d6dbfff69e841732bb6d26de6687e16 /Source
parentbf02d625325535f485512eba307cff54c08bb257 (diff)
downloadcmake-ce180cf810841ccc813ba7becc8043dd426fc966.tar.gz
cmake: Fix '-E copy foo .' to avoid clobbering file
Backport KWSys commit 92334e7670 (SystemTools: CopyFileAlways: avoid copying file over self, 2019-03-25) to the CMake 3.14 release branch. Fixes: #19075
Diffstat (limited to 'Source')
-rw-r--r--Source/kwsys/SystemTools.cxx8
1 files changed, 4 insertions, 4 deletions
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index cbdfe11759..d8904fed73 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -2307,10 +2307,6 @@ static bool CloneFileContent(const std::string& source,
bool SystemTools::CopyFileAlways(const std::string& source,
const std::string& destination)
{
- // If files are the same do not copy
- if (SystemTools::SameFile(source, destination)) {
- return true;
- }
mode_t perm = 0;
bool perms = SystemTools::GetPermissions(source, perm);
std::string real_destination = destination;
@@ -2331,6 +2327,10 @@ bool SystemTools::CopyFileAlways(const std::string& source,
} else {
destination_dir = SystemTools::GetFilenamePath(destination);
}
+ // If files are the same do not copy
+ if (SystemTools::SameFile(source, real_destination)) {
+ return true;
+ }
// Create destination directory