Files
cmake/Source/cmReturnCommand.cxx
T
Matthew Woehlke 1309532390 Diagnostics: Use new methods
Find places that are currently relying on diagnostic-specific message
types to issue diagnostics and replace these with calls to the new
diagnostic methods.
2026-04-16 15:10:35 -04:00

48 lines
1.4 KiB
C++

/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file LICENSE.rst or https://cmake.org/licensing for details. */
#include "cmReturnCommand.h"
#include <cm/string_view>
#include <cmext/string_view>
#include "cmDiagnostics.h"
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmPolicies.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
// cmReturnCommand
bool cmReturnCommand(std::vector<std::string> const& args,
cmExecutionStatus& status)
{
if (!args.empty()) {
switch (status.GetMakefile().GetPolicyStatus(cmPolicies::CMP0140)) {
case cmPolicies::WARN:
status.GetMakefile().IssueDiagnostic(
cmDiagnostics::CMD_AUTHOR,
cmStrCat(
cmPolicies::GetPolicyWarning(cmPolicies::CMP0140),
"\n"
"return() checks its arguments when the policy is set to NEW. "
"Since the policy is not set the OLD behavior will be used so "
"the arguments will be ignored."));
CM_FALLTHROUGH;
case cmPolicies::OLD:
return true;
default:
break;
}
if (args[0] != "PROPAGATE"_s) {
status.SetError(
cmStrCat("called with unsupported argument \"", args[0], '"'));
cmSystemTools::SetFatalErrorOccurred();
return false;
}
status.SetReturnInvoked({ args.begin() + 1, args.end() });
} else {
status.SetReturnInvoked();
}
return true;
}