1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
3 #include "cmReturnCommand.h"
5 #include <cm/string_view>
6 #include <cmext/string_view>
8 #include "cmExecutionStatus.h"
9 #include "cmMakefile.h"
10 #include "cmMessageType.h"
11 #include "cmPolicies.h"
12 #include "cmStringAlgorithms.h"
13 #include "cmSystemTools.h"
16 bool cmReturnCommand(std::vector
<std::string
> const& args
,
17 cmExecutionStatus
& status
)
20 switch (status
.GetMakefile().GetPolicyStatus(cmPolicies::CMP0140
)) {
21 case cmPolicies::WARN
:
22 status
.GetMakefile().IssueMessage(
23 MessageType::AUTHOR_WARNING
,
25 cmPolicies::GetPolicyWarning(cmPolicies::CMP0140
), '\n',
26 "return() checks its arguments when the policy is set to NEW. "
27 "Since the policy is not set the OLD behavior will be used so "
28 "the arguments will be ignored."));
32 case cmPolicies::REQUIRED_IF_USED
:
33 case cmPolicies::REQUIRED_ALWAYS
:
34 status
.GetMakefile().IssueMessage(
35 MessageType::FATAL_ERROR
,
36 cmStrCat('\n', cmPolicies::GetPolicyWarning(cmPolicies::CMP0140
)));
37 cmSystemTools::SetFatalErrorOccurred();
42 if (args
[0] != "PROPAGATE"_s
) {
44 cmStrCat("called with unsupported argument \"", args
[0], '"'));
45 cmSystemTools::SetFatalErrorOccurred();
48 status
.SetReturnInvoked({ args
.begin() + 1, args
.end() });
50 status
.SetReturnInvoked();