Add policy CMP0035 to disallow variable_requires

This commit is contained in:
Brad King 2013-10-21 11:58:48 -04:00
parent 178b9af186
commit 3969bb23aa
17 changed files with 55 additions and 29 deletions

View File

@ -1,7 +1,9 @@
variable_requires
-----------------
Deprecated. Use the if() command instead.
Disallowed. See CMake Policy :policy:`CMP0035`.
Use the if() command instead.
Assert satisfaction of an option's required variables.

View File

@ -64,3 +64,4 @@ All Policies
/policy/CMP0032
/policy/CMP0033
/policy/CMP0034
/policy/CMP0035

10
Help/policy/CMP0035.rst Normal file
View File

@ -0,0 +1,10 @@
CMP0035
-------
The :command:`variable_requires` command should not be called.
This command was introduced in November 2001 to perform some conditional
logic. It has long been replaced by the :command:`if` command.
.. |disallowed_version| replace:: 3.0.0
.. include:: DISALLOWED_COMMAND.txt

View File

@ -276,6 +276,11 @@ cmPolicies::cmPolicies()
CMP0034, "CMP0034",
"The utility_source command should not be called.",
3,0,0,0, cmPolicies::WARN);
this->DefinePolicy(
CMP0035, "CMP0035",
"The variable_requires command should not be called.",
3,0,0,0, cmPolicies::WARN);
}
cmPolicies::~cmPolicies()

View File

@ -86,6 +86,7 @@ public:
CMP0032, ///< Disallow command: output_required_files
CMP0033, ///< Disallow command: export_library_dependencies
CMP0034, ///< Disallow command: utility_source
CMP0035, ///< Disallow command: variable_requires
/** \brief Always the last entry.
*

View File

@ -16,6 +16,9 @@
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");

View File

@ -14,40 +14,15 @@
#include "cmCommand.h"
/** \class cmVariableRequiresCommand
* \brief Displays a message to the user
*
*/
class cmVariableRequiresCommand : public cmCommand
{
public:
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
{
return new cmVariableRequiresCommand;
}
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
cmTypeMacro(cmVariableRequiresCommand, cmCommand);
virtual cmCommand* Clone() { return new cmVariableRequiresCommand; }
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 "variable_requires";}
/** This command is kept for compatibility with older CMake versions. */
virtual bool IsDiscouraged() const
{
return true;
}
cmTypeMacro(cmVariableRequiresCommand, cmCommand);
virtual bool IsDiscouraged() const { return true; }
};

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,4 @@
CMake Error at CMP0035-NEW.cmake:2 \(variable_requires\):
The variable_requires command should not be called; see CMP0035.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)

View File

@ -0,0 +1,2 @@
cmake_policy(SET CMP0035 NEW)
variable_requires()

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,4 @@
CMake Error at CMP0035-OLD.cmake:2 \(variable_requires\):
variable_requires called with incorrect number of arguments
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)

View File

@ -0,0 +1,2 @@
cmake_policy(SET CMP0035 OLD)
variable_requires()

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,12 @@
CMake Warning \(dev\) at CMP0035-WARN.cmake:1 \(variable_requires\):
Policy CMP0035 is not set: The variable_requires command should not be
called. Run "cmake --help-policy CMP0035" 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 CMP0035-WARN.cmake:1 \(variable_requires\):
variable_requires called with incorrect number of arguments
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)

View File

@ -0,0 +1 @@
variable_requires()

View File

@ -7,6 +7,7 @@ foreach(p
CMP0032
CMP0033
CMP0034
CMP0035
)
run_cmake(${p}-WARN)
run_cmake(${p}-OLD)