summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/CMakeLists.txt2
-rw-r--r--Source/cmBuildNameCommand.cxx5
-rw-r--r--Source/cmCommand.cxx18
-rw-r--r--Source/cmCommand.h5
-rw-r--r--Source/cmCommands.cxx36
-rw-r--r--Source/cmDisallowedCommand.cxx31
-rw-r--r--Source/cmDisallowedCommand.h50
-rw-r--r--Source/cmExportLibraryDependenciesCommand.cxx6
-rw-r--r--Source/cmLoadCommandCommand.cxx5
-rw-r--r--Source/cmOutputRequiredFilesCommand.cxx5
-rw-r--r--Source/cmSubdirDependsCommand.cxx3
-rw-r--r--Source/cmUseMangledMesaCommand.cxx5
-rw-r--r--Source/cmUtilitySourceCommand.cxx5
-rw-r--r--Source/cmVariableRequiresCommand.cxx5
14 files changed, 111 insertions, 70 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 2835ee6..3b49f72 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -440,6 +440,8 @@ set(SRCS
cmCreateTestSourceList.h
cmDefinePropertyCommand.cxx
cmDefinePropertyCommand.h
+ cmDisallowedCommand.cxx
+ cmDisallowedCommand.h
cmEnableLanguageCommand.cxx
cmEnableLanguageCommand.h
cmEnableTestingCommand.cxx
diff --git a/Source/cmBuildNameCommand.cxx b/Source/cmBuildNameCommand.cxx
index 1e1cd21..12b69a8 100644
--- a/Source/cmBuildNameCommand.cxx
+++ b/Source/cmBuildNameCommand.cxx
@@ -16,11 +16,6 @@ class cmExecutionStatus;
bool cmBuildNameCommand::InitialPass(std::vector<std::string> const& args,
cmExecutionStatus&)
{
- if (this->Disallowed(
- cmPolicies::CMP0036,
- "The build_name command should not be called; see CMP0036.")) {
- return true;
- }
if (args.empty()) {
this->SetError("called with incorrect number of arguments");
return false;
diff --git a/Source/cmCommand.cxx b/Source/cmCommand.cxx
index 15bed27..d349c91 100644
--- a/Source/cmCommand.cxx
+++ b/Source/cmCommand.cxx
@@ -3,7 +3,6 @@
#include "cmCommand.h"
#include "cmMakefile.h"
-#include "cmake.h"
class cmExecutionStatus;
struct cmListFileArgument;
@@ -32,20 +31,3 @@ void cmCommand::SetError(const std::string& e)
{
this->Error = e;
}
-
-bool cmCommand::Disallowed(cmPolicies::PolicyID pol, const char* e)
-{
- switch (this->Makefile->GetPolicyStatus(pol)) {
- case cmPolicies::WARN:
- this->Makefile->IssueMessage(cmake::AUTHOR_WARNING,
- cmPolicies::GetPolicyWarning(pol));
- case cmPolicies::OLD:
- return false;
- case cmPolicies::REQUIRED_IF_USED:
- case cmPolicies::REQUIRED_ALWAYS:
- case cmPolicies::NEW:
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e);
- break;
- }
- return true;
-}
diff --git a/Source/cmCommand.h b/Source/cmCommand.h
index 32f4472..9107d85 100644
--- a/Source/cmCommand.h
+++ b/Source/cmCommand.h
@@ -7,8 +7,6 @@
#include <string>
#include <vector>
-#include "cmPolicies.h"
-
class cmExecutionStatus;
class cmMakefile;
struct cmListFileArgument;
@@ -104,9 +102,6 @@ public:
*/
void SetError(const std::string& e);
- /** Check if the command is disallowed by a policy. */
- bool Disallowed(cmPolicies::PolicyID pol, const char* e);
-
private:
cmCommand(cmCommand const&); // = delete;
cmCommand& operator=(cmCommand const&); // = delete;
diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx
index 4c5b093..a6754eb 100644
--- a/Source/cmCommands.cxx
+++ b/Source/cmCommands.cxx
@@ -77,6 +77,7 @@
#include "cmAuxSourceDirectoryCommand.h"
#include "cmBuildNameCommand.h"
#include "cmCMakeHostSystemInformationCommand.h"
+#include "cmDisallowedCommand.h"
#include "cmExportCommand.h"
#include "cmExportLibraryDependenciesCommand.h"
#include "cmFLTKWrapUICommand.h"
@@ -208,33 +209,52 @@ std::vector<cmCommand*> GetPredefinedCommands()
#if defined(CMAKE_BUILD_WITH_CMAKE)
commands.push_back(new cmAddCompileOptionsCommand);
commands.push_back(new cmAuxSourceDirectoryCommand);
- commands.push_back(new cmBuildNameCommand);
commands.push_back(new cmCMakeHostSystemInformationCommand);
commands.push_back(new cmExportCommand);
- commands.push_back(new cmExportLibraryDependenciesCommand);
commands.push_back(new cmFLTKWrapUICommand);
commands.push_back(new cmIncludeExternalMSProjectCommand);
commands.push_back(new cmInstallProgramsCommand);
commands.push_back(new cmLinkLibrariesCommand);
commands.push_back(new cmLoadCacheCommand);
- commands.push_back(new cmLoadCommandCommand);
- commands.push_back(new cmOutputRequiredFilesCommand);
commands.push_back(new cmQTWrapCPPCommand);
commands.push_back(new cmQTWrapUICommand);
commands.push_back(new cmRemoveCommand);
commands.push_back(new cmRemoveDefinitionsCommand);
commands.push_back(new cmSourceGroupCommand);
- commands.push_back(new cmSubdirDependsCommand);
commands.push_back(new cmTargetCompileDefinitionsCommand);
commands.push_back(new cmTargetCompileFeaturesCommand);
commands.push_back(new cmTargetCompileOptionsCommand);
commands.push_back(new cmTargetIncludeDirectoriesCommand);
commands.push_back(new cmTargetSourcesCommand);
- commands.push_back(new cmUseMangledMesaCommand);
- commands.push_back(new cmUtilitySourceCommand);
- commands.push_back(new cmVariableRequiresCommand);
commands.push_back(new cmVariableWatchCommand);
commands.push_back(new cmWriteFileCommand);
+
+ commands.push_back(new cmDisallowedCommand(
+ new cmBuildNameCommand, cmPolicies::CMP0036,
+ "The build_name command should not be called; see CMP0036."));
+ commands.push_back(new cmDisallowedCommand(
+ new cmExportLibraryDependenciesCommand, cmPolicies::CMP0033,
+ "The export_library_dependencies command should not be called; "
+ "see CMP0033."));
+ commands.push_back(new cmDisallowedCommand(
+ new cmLoadCommandCommand, cmPolicies::CMP0031,
+ "The load_command command should not be called; see CMP0031."));
+ commands.push_back(new cmDisallowedCommand(
+ new cmOutputRequiredFilesCommand, cmPolicies::CMP0032,
+ "The output_required_files command should not be called; "
+ "see CMP0032."));
+ commands.push_back(new cmDisallowedCommand(
+ new cmSubdirDependsCommand, cmPolicies::CMP0029,
+ "The subdir_depends command should not be called; see CMP0029."));
+ commands.push_back(new cmDisallowedCommand(
+ new cmUseMangledMesaCommand, cmPolicies::CMP0030,
+ "The use_mangled_mesa command should not be called; see CMP0030."));
+ commands.push_back(new cmDisallowedCommand(
+ new cmUtilitySourceCommand, cmPolicies::CMP0034,
+ "The utility_source command should not be called; see CMP0034."));
+ commands.push_back(new cmDisallowedCommand(
+ new cmVariableRequiresCommand, cmPolicies::CMP0035,
+ "The variable_requires command should not be called; see CMP0035."));
#endif
return commands;
diff --git a/Source/cmDisallowedCommand.cxx b/Source/cmDisallowedCommand.cxx
new file mode 100644
index 0000000..ce1965d
--- /dev/null
+++ b/Source/cmDisallowedCommand.cxx
@@ -0,0 +1,31 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmDisallowedCommand.h"
+
+#include "cmMakefile.h"
+#include "cmake.h"
+
+class cmExecutionStatus;
+
+bool cmDisallowedCommand::InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ switch (this->Makefile->GetPolicyStatus(this->Policy)) {
+ case cmPolicies::WARN:
+ this->Makefile->IssueMessage(cmake::AUTHOR_WARNING,
+ cmPolicies::GetPolicyWarning(this->Policy));
+ break;
+ case cmPolicies::OLD:
+ break;
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::NEW:
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, this->Message);
+ return true;
+ }
+
+ this->Command->SetMakefile(this->GetMakefile());
+ bool const ret = this->Command->InitialPass(args, status);
+ this->SetError(this->Command->GetError());
+ return ret;
+}
diff --git a/Source/cmDisallowedCommand.h b/Source/cmDisallowedCommand.h
new file mode 100644
index 0000000..9cf5e6f
--- /dev/null
+++ b/Source/cmDisallowedCommand.h
@@ -0,0 +1,50 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmDisallowedCommand_h
+#define cmDisallowedCommand_h
+
+#include <cmConfigure.h>
+#include <string>
+#include <vector>
+
+#include "cmCommand.h"
+#include "cmPolicies.h"
+
+class cmExecutionStatus;
+
+class cmDisallowedCommand : public cmCommand
+{
+public:
+ cmDisallowedCommand(cmCommand* command, cmPolicies::PolicyID policy,
+ const char* message)
+ : Command(command)
+ , Policy(policy)
+ , Message(message)
+ {
+ }
+
+ ~cmDisallowedCommand() CM_OVERRIDE { delete this->Command; }
+
+ cmCommand* Clone() CM_OVERRIDE
+ {
+ return new cmDisallowedCommand(this->Command->Clone(), this->Policy,
+ this->Message);
+ }
+
+ bool InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus& status) CM_OVERRIDE;
+
+ bool IsScriptable() const CM_OVERRIDE
+ {
+ return this->Command->IsScriptable();
+ }
+
+ std::string GetName() const CM_OVERRIDE { return this->Command->GetName(); }
+
+private:
+ cmCommand* Command;
+ cmPolicies::PolicyID Policy;
+ const char* Message;
+};
+
+#endif
diff --git a/Source/cmExportLibraryDependenciesCommand.cxx b/Source/cmExportLibraryDependenciesCommand.cxx
index ac4f040..e3fb412 100644
--- a/Source/cmExportLibraryDependenciesCommand.cxx
+++ b/Source/cmExportLibraryDependenciesCommand.cxx
@@ -23,12 +23,6 @@ class cmExecutionStatus;
bool cmExportLibraryDependenciesCommand::InitialPass(
std::vector<std::string> const& args, cmExecutionStatus&)
{
- if (this->Disallowed(
- cmPolicies::CMP0033,
- "The export_library_dependencies command should not be called; "
- "see CMP0033.")) {
- return true;
- }
if (args.empty()) {
this->SetError("called with incorrect number of arguments");
return false;
diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx
index b6743f1..39e5684 100644
--- a/Source/cmLoadCommandCommand.cxx
+++ b/Source/cmLoadCommandCommand.cxx
@@ -174,11 +174,6 @@ cmLoadedCommand::~cmLoadedCommand()
bool cmLoadCommandCommand::InitialPass(std::vector<std::string> const& args,
cmExecutionStatus&)
{
- if (this->Disallowed(
- cmPolicies::CMP0031,
- "The load_command command should not be called; see CMP0031.")) {
- return true;
- }
if (args.empty()) {
return true;
}
diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx
index 7a17f2c..f120971 100644
--- a/Source/cmOutputRequiredFilesCommand.cxx
+++ b/Source/cmOutputRequiredFilesCommand.cxx
@@ -495,11 +495,6 @@ protected:
bool cmOutputRequiredFilesCommand::InitialPass(
std::vector<std::string> const& args, cmExecutionStatus&)
{
- if (this->Disallowed(cmPolicies::CMP0032, "The output_required_files "
- "command should not be called; "
- "see CMP0032.")) {
- return true;
- }
if (args.size() != 2) {
this->SetError("called with incorrect number of arguments");
return false;
diff --git a/Source/cmSubdirDependsCommand.cxx b/Source/cmSubdirDependsCommand.cxx
index 9259836..36e84d5 100644
--- a/Source/cmSubdirDependsCommand.cxx
+++ b/Source/cmSubdirDependsCommand.cxx
@@ -9,8 +9,5 @@ class cmExecutionStatus;
bool cmSubdirDependsCommand::InitialPass(std::vector<std::string> const&,
cmExecutionStatus&)
{
- this->Disallowed(
- cmPolicies::CMP0029,
- "The subdir_depends command should not be called; see CMP0029.");
return true;
}
diff --git a/Source/cmUseMangledMesaCommand.cxx b/Source/cmUseMangledMesaCommand.cxx
index 3e72d75..3d57f0e 100644
--- a/Source/cmUseMangledMesaCommand.cxx
+++ b/Source/cmUseMangledMesaCommand.cxx
@@ -13,11 +13,6 @@ class cmExecutionStatus;
bool cmUseMangledMesaCommand::InitialPass(std::vector<std::string> const& args,
cmExecutionStatus&)
{
- if (this->Disallowed(
- cmPolicies::CMP0030,
- "The use_mangled_mesa command should not be called; see CMP0030.")) {
- return true;
- }
// expected two arguments:
// arguement one: the full path to gl_mangle.h
// arguement two : directory for output of edited headers
diff --git a/Source/cmUtilitySourceCommand.cxx b/Source/cmUtilitySourceCommand.cxx
index 3b78abe..9b24a74 100644
--- a/Source/cmUtilitySourceCommand.cxx
+++ b/Source/cmUtilitySourceCommand.cxx
@@ -16,11 +16,6 @@ class cmExecutionStatus;
bool cmUtilitySourceCommand::InitialPass(std::vector<std::string> const& args,
cmExecutionStatus&)
{
- if (this->Disallowed(
- cmPolicies::CMP0034,
- "The utility_source command should not be called; see CMP0034.")) {
- return true;
- }
if (args.size() < 3) {
this->SetError("called with incorrect number of arguments");
return false;
diff --git a/Source/cmVariableRequiresCommand.cxx b/Source/cmVariableRequiresCommand.cxx
index 1eb1f20..bff6ec5 100644
--- a/Source/cmVariableRequiresCommand.cxx
+++ b/Source/cmVariableRequiresCommand.cxx
@@ -13,11 +13,6 @@ class cmExecutionStatus;
bool cmVariableRequiresCommand::InitialPass(
std::vector<std::string> const& args, cmExecutionStatus&)
{
- if (this->Disallowed(
- cmPolicies::CMP0035,
- "The variable_requires command should not be called; see CMP0035.")) {
- return true;
- }
if (args.size() < 3) {
this->SetError("called with incorrect number of arguments");
return false;