summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-04-15 16:02:16 (GMT)
committerBrad King <brad.king@kitware.com>2021-04-15 16:40:37 (GMT)
commitc2d2772f15d08f006c0841d4caf028c41f315ca4 (patch)
treedf1e7819c2e9461dc5401ba9d740ad2a1d070eee
parent79a2f1e22a4ff95d7d96478d579a7f52b3c289da (diff)
downloadCMake-c2d2772f15d08f006c0841d4caf028c41f315ca4.zip
CMake-c2d2772f15d08f006c0841d4caf028c41f315ca4.tar.gz
CMake-c2d2772f15d08f006c0841d4caf028c41f315ca4.tar.bz2
try_compile: Improve error message when a file cannot be removed
-rw-r--r--Source/cmCoreTryCompile.cxx14
1 files changed, 9 insertions, 5 deletions
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index 6672aa6..cb84d1d 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -1015,17 +1015,21 @@ void cmCoreTryCompile::CleanupFiles(std::string const& binDir)
// cannot delete them immediately. Try a few times.
cmSystemTools::WindowsFileRetry retry =
cmSystemTools::GetWindowsFileRetry();
- while (!cmSystemTools::RemoveFile(fullPath) && --retry.Count &&
- cmSystemTools::FileExists(fullPath)) {
+ cmsys::Status status;
+ while (!((status = cmSystemTools::RemoveFile(fullPath))) &&
+ --retry.Count && cmSystemTools::FileExists(fullPath)) {
cmSystemTools::Delay(retry.Delay);
}
if (retry.Count == 0)
#else
- if (!cmSystemTools::RemoveFile(fullPath))
+ cmsys::Status status = cmSystemTools::RemoveFile(fullPath);
+ if (!status)
#endif
{
- std::string m = "Remove failed on file: " + fullPath;
- cmSystemTools::ReportLastSystemError(m.c_str());
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("The file:\n ", fullPath,
+ "\ncould not be removed:\n ", status.GetString()));
}
}
}