Add policy CMP0031 to disallow load_command

This commit is contained in:
Brad King 2013-10-18 12:41:54 -04:00
parent 97268cf5b7
commit aa76518f8b
17 changed files with 56 additions and 22 deletions

View File

@ -1,6 +1,8 @@
load_command
------------
Disallowed. See CMake Policy :policy:`CMP0031`.
Load a command into a running CMake.
::

View File

@ -60,3 +60,4 @@ All Policies
/policy/CMP0028
/policy/CMP0029
/policy/CMP0030
/policy/CMP0031

13
Help/policy/CMP0031.rst Normal file
View File

@ -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

View File

@ -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;

View File

@ -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);
};

View File

@ -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()

View File

@ -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.
*

View File

@ -0,0 +1 @@
1

View File

@ -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\)

View File

@ -0,0 +1,2 @@
cmake_policy(SET CMP0031 NEW)
load_command()

View File

@ -0,0 +1 @@
1

View File

@ -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\)

View File

@ -0,0 +1,2 @@
cmake_policy(SET CMP0031 OLD)
load_command(bogus_command)

View File

@ -0,0 +1 @@
1

View File

@ -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\)

View File

@ -0,0 +1 @@
load_command(bogus_command)

View File

@ -3,6 +3,7 @@ include(RunCMake)
foreach(p
CMP0029
CMP0030
CMP0031
)
run_cmake(${p}-WARN)
run_cmake(${p}-OLD)