summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKWSys Upstream <kwrobot@kitware.com>2020-02-17 16:58:07 (GMT)
committerBrad King <brad.king@kitware.com>2020-02-17 16:59:07 (GMT)
commit96dd383ceb6568ca4e02c71b271cca394ade6e55 (patch)
tree3e20d3c0662df28cda5a638df3b14d95e794239d
parent9e27e52d4b0fee729f9a3bef710efed290ef9900 (diff)
downloadCMake-96dd383ceb6568ca4e02c71b271cca394ade6e55.zip
CMake-96dd383ceb6568ca4e02c71b271cca394ade6e55.tar.gz
CMake-96dd383ceb6568ca4e02c71b271cca394ade6e55.tar.bz2
KWSys 2020-02-17 (3e117fe1)
Code extracted from: https://gitlab.kitware.com/utils/kwsys.git at commit 3e117fe1e008aeca4a4f33a431b196848cc34e11 (master). Upstream Shortlog ----------------- Brad King (1): c2420a42 SystemTools: Revert "CopyFileIfDifferent: Ensure that source is a file" Julien Schueller (1): c3acc96d CMake: Fix psapi lib name on case-sensitive fs Sebastian Lipponer (2): 573713fa SystemTools: CopyFileIfDifferent: Ensure that source is a file ea77593a SystemTools: CopyFileIfDifferent: Fix endless recursion
-rw-r--r--CMakeLists.txt2
-rw-r--r--SystemTools.cxx15
-rw-r--r--testSystemTools.cxx9
3 files changed, 19 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 09bcdb9..aa788e9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -536,7 +536,7 @@ IF(KWSYS_USE_SystemInformation)
ENDIF()
IF(WIN32)
INCLUDE(CheckSymbolExists)
- SET(CMAKE_REQUIRED_LIBRARIES Psapi)
+ SET(CMAKE_REQUIRED_LIBRARIES psapi)
CHECK_SYMBOL_EXISTS(GetProcessMemoryInfo "windows.h;psapi.h" KWSYS_SYS_HAS_PSAPI)
UNSET(CMAKE_REQUIRED_LIBRARIES)
IF(KWSYS_SYS_HAS_PSAPI)
diff --git a/SystemTools.cxx b/SystemTools.cxx
index 39873e6..d27081b 100644
--- a/SystemTools.cxx
+++ b/SystemTools.cxx
@@ -2186,12 +2186,15 @@ bool SystemTools::CopyFileIfDifferent(const std::string& source,
// FilesDiffer does not handle file to directory compare
if (SystemTools::FileIsDirectory(destination)) {
const std::string new_destination = FileInDir(source, destination);
- return SystemTools::CopyFileIfDifferent(source, new_destination);
- }
- // source and destination are files so do a copy if they
- // are different
- if (SystemTools::FilesDiffer(source, destination)) {
- return SystemTools::CopyFileAlways(source, destination);
+ if (!SystemTools::ComparePath(new_destination, destination)) {
+ return SystemTools::CopyFileIfDifferent(source, new_destination);
+ }
+ } else {
+ // source and destination are files so do a copy if they
+ // are different
+ if (SystemTools::FilesDiffer(source, destination)) {
+ return SystemTools::CopyFileAlways(source, destination);
+ }
}
// at this point the files must be the same so return true
return true;
diff --git a/testSystemTools.cxx b/testSystemTools.cxx
index 1f3a15b..3f6eeb8 100644
--- a/testSystemTools.cxx
+++ b/testSystemTools.cxx
@@ -1074,6 +1074,15 @@ static bool CheckCopyFileIfDifferent()
}
}
+ if (!kwsys::SystemTools::MakeDirectory("dir_a") ||
+ !kwsys::SystemTools::MakeDirectory("dir_b")) {
+ return false;
+ }
+
+ if (!kwsys::SystemTools::CopyFileIfDifferent("dir_a/", "dir_b")) {
+ ret = false;
+ }
+
return ret;
}