summaryrefslogtreecommitdiffstats
path: root/Source/cmState.cxx
diff options
context:
space:
mode:
authorRegina Pfeifer <regina@mailbox.org>2019-08-13 11:42:59 (GMT)
committerRegina Pfeifer <regina@mailbox.org>2019-08-13 11:48:10 (GMT)
commit86bf1eef7587b837057f098927fb6e7e10149c66 (patch)
treeeef40a2545a856af584ecd1c8bd81067463fd14a /Source/cmState.cxx
parent7d194f7d8331a127e0b2b921dc6bc0abfe21a0f5 (diff)
downloadCMake-86bf1eef7587b837057f098927fb6e7e10149c66.zip
CMake-86bf1eef7587b837057f098927fb6e7e10149c66.tar.gz
CMake-86bf1eef7587b837057f098927fb6e7e10149c66.tar.bz2
cmState: Support free function disallowed commands
Diffstat (limited to 'Source/cmState.cxx')
-rw-r--r--Source/cmState.cxx47
1 files changed, 41 insertions, 6 deletions
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index 1ea72e1..4f694e2 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -432,6 +432,20 @@ void cmState::AddBuiltinCommand(std::string const& name, Command command)
this->BuiltinCommands.emplace(name, std::move(command));
}
+static bool InvokeBuiltinCommand(cmState::BuiltinCommand command,
+ std::vector<cmListFileArgument> const& args,
+ cmExecutionStatus& status)
+{
+ cmMakefile& mf = status.GetMakefile();
+ std::vector<std::string> expandedArguments;
+ if (!mf.ExpandArguments(args, expandedArguments)) {
+ // There was an error expanding arguments. It was already
+ // reported, so we can skip this command without error.
+ return true;
+ }
+ return command(expandedArguments, status);
+}
+
void cmState::AddBuiltinCommand(std::string const& name,
BuiltinCommand command)
{
@@ -439,13 +453,34 @@ void cmState::AddBuiltinCommand(std::string const& name,
name,
[command](const std::vector<cmListFileArgument>& args,
cmExecutionStatus& status) -> bool {
- std::vector<std::string> expandedArguments;
- if (!status.GetMakefile().ExpandArguments(args, expandedArguments)) {
- // There was an error expanding arguments. It was already
- // reported, so we can skip this command without error.
- return true;
+ return InvokeBuiltinCommand(command, args, status);
+ });
+}
+
+void cmState::AddDisallowedCommand(std::string const& name,
+ BuiltinCommand command,
+ cmPolicies::PolicyID policy,
+ const char* message)
+{
+ this->AddBuiltinCommand(
+ name,
+ [command, policy, message](const std::vector<cmListFileArgument>& args,
+ cmExecutionStatus& status) -> bool {
+ cmMakefile& mf = status.GetMakefile();
+ switch (mf.GetPolicyStatus(policy)) {
+ case cmPolicies::WARN:
+ mf.IssueMessage(MessageType::AUTHOR_WARNING,
+ cmPolicies::GetPolicyWarning(policy));
+ break;
+ case cmPolicies::OLD:
+ break;
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::NEW:
+ mf.IssueMessage(MessageType::FATAL_ERROR, message);
+ return true;
}
- return command(expandedArguments, status);
+ return InvokeBuiltinCommand(command, args, status);
});
}