summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2013-10-18 16:41:54 (GMT)
committerBrad King <brad.king@kitware.com>2013-10-22 13:09:52 (GMT)
commitaa76518f8bfd821f000d1779066eb7614cdd079b (patch)
tree4005fa79df546cbf0de9bfb2f0610b27a9b65c3d
parent97268cf5b7626febb06d04c2201ace397a4863fd (diff)
downloadCMake-aa76518f8bfd821f000d1779066eb7614cdd079b.zip
CMake-aa76518f8bfd821f000d1779066eb7614cdd079b.tar.gz
CMake-aa76518f8bfd821f000d1779066eb7614cdd079b.tar.bz2
Add policy CMP0031 to disallow load_command
-rw-r--r--Help/command/load_command.rst2
-rw-r--r--Help/manual/cmake-policies.7.rst1
-rw-r--r--Help/policy/CMP0031.rst13
-rw-r--r--Source/cmLoadCommandCommand.cxx3
-rw-r--r--Source/cmLoadCommandCommand.h24
-rw-r--r--Source/cmPolicies.cxx5
-rw-r--r--Source/cmPolicies.h1
-rw-r--r--Tests/RunCMake/DisallowedCommands/CMP0031-NEW-result.txt1
-rw-r--r--Tests/RunCMake/DisallowedCommands/CMP0031-NEW-stderr.txt4
-rw-r--r--Tests/RunCMake/DisallowedCommands/CMP0031-NEW.cmake2
-rw-r--r--Tests/RunCMake/DisallowedCommands/CMP0031-OLD-result.txt1
-rw-r--r--Tests/RunCMake/DisallowedCommands/CMP0031-OLD-stderr.txt4
-rw-r--r--Tests/RunCMake/DisallowedCommands/CMP0031-OLD.cmake2
-rw-r--r--Tests/RunCMake/DisallowedCommands/CMP0031-WARN-result.txt1
-rw-r--r--Tests/RunCMake/DisallowedCommands/CMP0031-WARN-stderr.txt12
-rw-r--r--Tests/RunCMake/DisallowedCommands/CMP0031-WARN.cmake1
-rw-r--r--Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake1
17 files changed, 56 insertions, 22 deletions
diff --git a/Help/command/load_command.rst b/Help/command/load_command.rst
index 63f23be..fc316d4 100644
--- a/Help/command/load_command.rst
+++ b/Help/command/load_command.rst
@@ -1,6 +1,8 @@
load_command
------------
+Disallowed. See CMake Policy :policy:`CMP0031`.
+
Load a command into a running CMake.
::
diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst
index c1251f0..ab1bf39 100644
--- a/Help/manual/cmake-policies.7.rst
+++ b/Help/manual/cmake-policies.7.rst
@@ -60,3 +60,4 @@ All Policies
/policy/CMP0028
/policy/CMP0029
/policy/CMP0030
+ /policy/CMP0031
diff --git a/Help/policy/CMP0031.rst b/Help/policy/CMP0031.rst
new file mode 100644
index 0000000..e97dd0a
--- /dev/null
+++ b/Help/policy/CMP0031.rst
@@ -0,0 +1,13 @@
+CMP0031
+-------
+
+The :command:`load_command` command should not be called.
+
+This command was added in August 2002 to allow projects to add
+arbitrary commands implemented in C or C++. However, it does
+not work when the toolchain in use does not match the ABI of
+the CMake process. It has been mostly superseded by the
+:command:`macro` and :command:`function` commands.
+
+.. |disallowed_version| replace:: 3.0.0
+.. include:: DISALLOWED_COMMAND.txt
diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx
index 84dd299..21ee0fe 100644
--- a/Source/cmLoadCommandCommand.cxx
+++ b/Source/cmLoadCommandCommand.cxx
@@ -189,6 +189,9 @@ 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.size() < 1 )
{
return true;
diff --git a/Source/cmLoadCommandCommand.h b/Source/cmLoadCommandCommand.h
index 918f32b..11bcf09 100644
--- a/Source/cmLoadCommandCommand.h
+++ b/Source/cmLoadCommandCommand.h
@@ -14,34 +14,14 @@
#include "cmCommand.h"
-/** \class cmLoadCommandCommand
- * \brief Load in a Command plugin
- *
- * cmLoadCommandCommand loads a command into CMake
- */
class cmLoadCommandCommand : public cmCommand
{
public:
- /**
- * This is a virtual constructor for the command.
- */
- virtual cmCommand* Clone()
- {
- return new cmLoadCommandCommand;
- }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
+ virtual cmCommand* Clone() { return new cmLoadCommandCommand; }
virtual bool InitialPass(std::vector<std::string> const& args,
cmExecutionStatus &status);
-
- /**
- * The name of the command as specified in CMakeList.txt.
- */
virtual const char* GetName() const {return "load_command";}
-
+ virtual bool IsDiscouraged() const { return true; }
cmTypeMacro(cmLoadCommandCommand, cmCommand);
};
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index fdd3bd0..03e898e 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -256,6 +256,11 @@ cmPolicies::cmPolicies()
CMP0030, "CMP0030",
"The use_mangled_mesa command should not be called.",
3,0,0,0, cmPolicies::WARN);
+
+ this->DefinePolicy(
+ CMP0031, "CMP0031",
+ "The load_command command should not be called.",
+ 3,0,0,0, cmPolicies::WARN);
}
cmPolicies::~cmPolicies()
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index 6de168e..597296b 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -82,6 +82,7 @@ public:
CMP0028, ///< Double colon in target name means ALIAS or IMPORTED target.
CMP0029, ///< Disallow command: subdir_depends
CMP0030, ///< Disallow command: use_mangled_mesa
+ CMP0031, ///< Disallow command: load_command
/** \brief Always the last entry.
*
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0031-NEW-result.txt b/Tests/RunCMake/DisallowedCommands/CMP0031-NEW-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0031-NEW-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0031-NEW-stderr.txt b/Tests/RunCMake/DisallowedCommands/CMP0031-NEW-stderr.txt
new file mode 100644
index 0000000..78c2236
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0031-NEW-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at CMP0031-NEW.cmake:2 \(load_command\):
+ The load_command command should not be called; see CMP0031.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0031-NEW.cmake b/Tests/RunCMake/DisallowedCommands/CMP0031-NEW.cmake
new file mode 100644
index 0000000..3d9caf2
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0031-NEW.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0031 NEW)
+load_command()
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0031-OLD-result.txt b/Tests/RunCMake/DisallowedCommands/CMP0031-OLD-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0031-OLD-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0031-OLD-stderr.txt b/Tests/RunCMake/DisallowedCommands/CMP0031-OLD-stderr.txt
new file mode 100644
index 0000000..ba198d6
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0031-OLD-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at CMP0031-OLD.cmake:2 \(load_command\):
+ load_command Attempt to load command failed from file.*bogus_command.*
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0031-OLD.cmake b/Tests/RunCMake/DisallowedCommands/CMP0031-OLD.cmake
new file mode 100644
index 0000000..8fedf98
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0031-OLD.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0031 OLD)
+load_command(bogus_command)
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0031-WARN-result.txt b/Tests/RunCMake/DisallowedCommands/CMP0031-WARN-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0031-WARN-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0031-WARN-stderr.txt b/Tests/RunCMake/DisallowedCommands/CMP0031-WARN-stderr.txt
new file mode 100644
index 0000000..4cb65b3
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0031-WARN-stderr.txt
@@ -0,0 +1,12 @@
+CMake Warning \(dev\) at CMP0031-WARN.cmake:1 \(load_command\):
+ Policy CMP0031 is not set: The load_command command should not be called.
+ Run "cmake --help-policy CMP0031" for policy details. Use the cmake_policy
+ command to set the policy and suppress this warning.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Error at CMP0031-WARN.cmake:1 \(load_command\):
+ load_command Attempt to load command failed from file.*bogus_command.*
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0031-WARN.cmake b/Tests/RunCMake/DisallowedCommands/CMP0031-WARN.cmake
new file mode 100644
index 0000000..c9d99fc
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0031-WARN.cmake
@@ -0,0 +1 @@
+load_command(bogus_command)
diff --git a/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake b/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake
index 1945210..aea2353 100644
--- a/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake
+++ b/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake
@@ -3,6 +3,7 @@ include(RunCMake)
foreach(p
CMP0029
CMP0030
+ CMP0031
)
run_cmake(${p}-WARN)
run_cmake(${p}-OLD)