Commit aa76518f authored by Brad King's avatar Brad King

Add policy CMP0031 to disallow load_command

parent 97268cf5
load_command
------------
Disallowed. See CMake Policy :policy:`CMP0031`.
Load a command into a running CMake.
::
......
......@@ -60,3 +60,4 @@ All Policies
/policy/CMP0028
/policy/CMP0029
/policy/CMP0030
/policy/CMP0031
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
......@@ -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;
......
......@@ -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);
};
......
......@@ -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()
......
......@@ -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.
*
......
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\)
cmake_policy(SET CMP0031 NEW)
load_command()
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\)
cmake_policy(SET CMP0031 OLD)
load_command(bogus_command)
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\)
......@@ -3,6 +3,7 @@ include(RunCMake)
foreach(p
CMP0029
CMP0030
CMP0031
)
run_cmake(${p}-WARN)
run_cmake(${p}-OLD)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment