summaryrefslogtreecommitdiffstats
path: root/Source/cmState.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-08-21 14:47:29 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-08-21 14:47:47 (GMT)
commitde2c73d84f767e8d80ed310151384554506ff49b (patch)
tree65b0e49d42d4dd8731adb976a6bdc8b9157f1a92 /Source/cmState.cxx
parent98972371e4a768c36d4169431392fe727dcac2ee (diff)
parentc55fb044a9cf20a449f9d5ebc5d88c6de279786d (diff)
downloadCMake-de2c73d84f767e8d80ed310151384554506ff49b.zip
CMake-de2c73d84f767e8d80ed310151384554506ff49b.tar.gz
CMake-de2c73d84f767e8d80ed310151384554506ff49b.tar.bz2
Merge topic 'free-disallowed'
c55fb044a9 cmBuildNameCommand: Implement as free function 86bf1eef75 cmState: Support free function disallowed commands Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3688
Diffstat (limited to 'Source/cmState.cxx')
-rw-r--r--Source/cmState.cxx48
1 files changed, 42 insertions, 6 deletions
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index 07f4dec..b6f1808 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -19,6 +19,7 @@
#include "cmGlobVerificationManager.h"
#include "cmListFileCache.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmStatePrivate.h"
#include "cmStateSnapshot.h"
#include "cmStringAlgorithms.h"
@@ -432,6 +433,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 +454,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);
});
}