diff options
author | Brad King <brad.king@kitware.com> | 2021-04-15 16:02:16 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-04-15 16:40:37 (GMT) |
commit | c2d2772f15d08f006c0841d4caf028c41f315ca4 (patch) | |
tree | df1e7819c2e9461dc5401ba9d740ad2a1d070eee | |
parent | 79a2f1e22a4ff95d7d96478d579a7f52b3c289da (diff) | |
download | CMake-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.cxx | 14 |
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())); } } } |