mirror of
https://github.com/Kitware/CMake.git
synced 2026-08-07 00:00:57 +00:00
try_compile: Report underlying error when COPY_FILE fails
This commit is contained in:
@@ -1099,23 +1099,35 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
|
|||||||
|
|
||||||
if ((res == 0) && arguments.CopyFileTo) {
|
if ((res == 0) && arguments.CopyFileTo) {
|
||||||
std::string const& copyFile = *arguments.CopyFileTo;
|
std::string const& copyFile = *arguments.CopyFileTo;
|
||||||
if (this->OutputFile.empty() ||
|
cmsys::SystemTools::CopyStatus status =
|
||||||
!cmSystemTools::CopyFileAlways(this->OutputFile, copyFile)) {
|
cmSystemTools::CopyFileAlways(this->OutputFile, copyFile);
|
||||||
std::ostringstream emsg;
|
if (!status) {
|
||||||
/* clang-format off */
|
std::string err = status.GetString();
|
||||||
emsg << "Cannot copy output executable\n"
|
switch (status.Path) {
|
||||||
<< " '" << this->OutputFile << "'\n"
|
case cmsys::SystemTools::CopyStatus::SourcePath:
|
||||||
<< "to destination specified by COPY_FILE:\n"
|
err = cmStrCat(err, " (input)");
|
||||||
<< " '" << copyFile << "'\n";
|
break;
|
||||||
/* clang-format on */
|
case cmsys::SystemTools::CopyStatus::DestPath:
|
||||||
if (!this->FindErrorMessage.empty()) {
|
err = cmStrCat(err, " (output)");
|
||||||
emsg << this->FindErrorMessage;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
/* clang-format off */
|
||||||
|
err = cmStrCat(
|
||||||
|
"Cannot copy output executable\n",
|
||||||
|
" '", this->OutputFile, "'\n",
|
||||||
|
"to destination specified by COPY_FILE:\n",
|
||||||
|
" '", copyFile, "'\n",
|
||||||
|
"because:\n",
|
||||||
|
" ", err, "\n",
|
||||||
|
this->FindErrorMessage);
|
||||||
|
/* clang-format on */
|
||||||
if (!arguments.CopyFileError) {
|
if (!arguments.CopyFileError) {
|
||||||
this->Makefile->IssueMessage(MessageType::FATAL_ERROR, emsg.str());
|
this->Makefile->IssueMessage(MessageType::FATAL_ERROR, err);
|
||||||
return cm::nullopt;
|
return cm::nullopt;
|
||||||
}
|
}
|
||||||
copyFileErrorMessage = emsg.str();
|
copyFileErrorMessage = std::move(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user