execute_process: Allow setting default COMMAND_ERROR_IS_FATAL value

Issue: #26576
This commit is contained in:
Martin Duffy
2025-01-13 08:16:21 -05:00
parent 85035dd954
commit 3ece058d97
17 changed files with 126 additions and 9 deletions
+19 -6
View File
@@ -177,12 +177,25 @@ bool cmExecuteProcessCommand(std::vector<std::string> const& args,
}
}
if (!arguments.CommandErrorIsFatal.empty()) {
if (arguments.CommandErrorIsFatal != "ANY"_s &&
arguments.CommandErrorIsFatal != "LAST"_s) {
status.SetError("COMMAND_ERROR_IS_FATAL option can be ANY or LAST");
std::string commandErrorIsFatal = arguments.CommandErrorIsFatal;
if (commandErrorIsFatal.empty() && arguments.ResultVariable.empty() &&
arguments.ResultsVariable.empty()) {
commandErrorIsFatal = status.GetMakefile().GetSafeDefinition(
"CMAKE_EXECUTE_PROCESS_COMMAND_ERROR_IS_FATAL");
}
if (!commandErrorIsFatal.empty() && commandErrorIsFatal != "ANY"_s &&
commandErrorIsFatal != "LAST"_s && commandErrorIsFatal != "NONE"_s) {
if (!arguments.CommandErrorIsFatal.empty()) {
status.SetError(
"COMMAND_ERROR_IS_FATAL option can be ANY, LAST or NONE");
return false;
}
status.SetError(cmStrCat(
"Using CMAKE_EXECUTE_PROCESS_COMMAND_ERROR_IS_FATAL with invalid value "
"\"",
commandErrorIsFatal, "\". This variable can be ANY, LAST or NONE"));
return false;
}
// Create a process instance.
cmUVProcessChainBuilder builder;
@@ -479,7 +492,7 @@ bool cmExecuteProcessCommand(std::vector<std::string> const& args,
exception.second);
};
if (arguments.CommandErrorIsFatal == "ANY"_s) {
if (commandErrorIsFatal == "ANY"_s) {
bool ret = true;
if (timedOut) {
status.SetError("Process terminated due to timeout");
@@ -510,7 +523,7 @@ bool cmExecuteProcessCommand(std::vector<std::string> const& args,
}
}
if (arguments.CommandErrorIsFatal == "LAST"_s) {
if (commandErrorIsFatal == "LAST"_s) {
bool ret = true;
if (timedOut) {
status.SetError("Process terminated due to timeout");