diff options
author | Brad King <brad.king@kitware.com> | 2020-02-18 16:48:53 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-02-18 16:49:00 (GMT) |
commit | 308563940afbaf9a8b0ac463ba83df07aa374fd6 (patch) | |
tree | 5aaf58ab4554acbe5f2b4df92a8f198514ac4b9e /Source | |
parent | 084c14d9523fbb05ac0da1d4f85482f38803919d (diff) | |
parent | 0f9111be3603d076de9ff361a94776ae84d61022 (diff) | |
download | CMake-308563940afbaf9a8b0ac463ba83df07aa374fd6.zip CMake-308563940afbaf9a8b0ac463ba83df07aa374fd6.tar.gz CMake-308563940afbaf9a8b0ac463ba83df07aa374fd6.tar.bz2 |
Merge topic 'update-kwsys'
0f9111be36 Merge branch 'backport-kwsys-copy-fix' into update-kwsys
ce59cabc70 KWSys: SystemTools: CopyFileIfDifferent: Fix endless recursion
fc6eced05e Merge branch 'upstream-KWSys' into update-kwsys
96dd383ceb KWSys 2020-02-17 (3e117fe1)
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4361
Diffstat (limited to 'Source')
-rw-r--r-- | Source/kwsys/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Source/kwsys/SystemTools.cxx | 15 | ||||
-rw-r--r-- | Source/kwsys/testSystemTools.cxx | 9 |
3 files changed, 19 insertions, 7 deletions
diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt index 09bcdb9..aa788e9 100644 --- a/Source/kwsys/CMakeLists.txt +++ b/Source/kwsys/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/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 39873e6..d27081b 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/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/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx index 1f3a15b..3f6eeb8 100644 --- a/Source/kwsys/testSystemTools.cxx +++ b/Source/kwsys/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; } |