Merge topic 'cmFileCopier-error-loss'

a820877d03 errors: avoid constructing a stream before getting the last error
5cf7018af6 cmFileCopier: remember error statuses and get their strings
0639a32d3a cmFileTimes: return status codes from APIs

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !9023
This commit is contained in:
Brad King
2023-12-05 14:23:31 +00:00
committed by Kitware Robot
7 changed files with 77 additions and 59 deletions
+5 -7
View File
@@ -629,13 +629,11 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
// now create a CMakeLists.txt file in that directory
FILE* fout = cmsys::SystemTools::Fopen(outFileName, "w");
if (!fout) {
std::ostringstream e;
/* clang-format off */
e << "Failed to open\n"
" " << outFileName << "\n"
<< cmSystemTools::GetLastSystemError();
/* clang-format on */
this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
this->Makefile->IssueMessage(
MessageType::FATAL_ERROR,
cmStrCat("Failed to open\n"
" ",
outFileName, '\n', cmSystemTools::GetLastSystemError()));
return cm::nullopt;
}