Add policy CMP0036 to disallow build_name

This commit is contained in:
Brad King 2013-10-21 13:12:18 -04:00
parent 3969bb23aa
commit 6c9194488a
17 changed files with 58 additions and 35 deletions

View File

@ -1,7 +1,9 @@
build_name
----------
Deprecated. Use ${CMAKE_SYSTEM} and ${CMAKE_CXX_COMPILER} instead.
Disallowed. See CMake Policy :policy:`CMP0036`.
Use ${CMAKE_SYSTEM} and ${CMAKE_CXX_COMPILER} instead.
::

View File

@ -65,3 +65,4 @@ All Policies
/policy/CMP0033
/policy/CMP0034
/policy/CMP0035
/policy/CMP0036

12
Help/policy/CMP0036.rst Normal file
View File

@ -0,0 +1,12 @@
CMP0036
-------
The :command:`build_name` command should not be called.
This command was added in May 2001 to compute a name for the current
operating system and compiler combination. The command has long been
documented as discouraged and replaced by the :variable:`CMAKE_SYSTEM`
and :variable:`CMAKE_<LANG>_COMPILER` variables.
.. |disallowed_version| replace:: 3.0.0
.. include:: DISALLOWED_COMMAND.txt

View File

@ -17,6 +17,9 @@
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.size() < 1 )
{
this->SetError("called with incorrect number of arguments");

View File

@ -14,46 +14,16 @@
#include "cmCommand.h"
/** \class cmBuildNameCommand
* \brief build_name command
*
* cmBuildNameCommand implements the build_name CMake command
*/
class cmBuildNameCommand : public cmCommand
{
public:
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
{
return new cmBuildNameCommand;
}
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
cmTypeMacro(cmBuildNameCommand, cmCommand);
virtual cmCommand* Clone() { return new cmBuildNameCommand; }
virtual bool InitialPass(std::vector<std::string> const& args,
cmExecutionStatus &status);
/**
* This determines if the command is invoked when in script mode.
*/
virtual bool IsScriptable() const { return true; }
/**
* The name of the command as specified in CMakeList.txt.
*/
virtual const char* GetName() const {return "build_name";}
/** This command is kept for compatibility with older CMake versions. */
virtual bool IsDiscouraged() const
{
return true;
}
cmTypeMacro(cmBuildNameCommand, cmCommand);
virtual bool IsScriptable() const { return true; }
virtual bool IsDiscouraged() const { return true; }
};

View File

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

View File

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

View File

@ -0,0 +1 @@
1

View File

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

View File

@ -0,0 +1,2 @@
cmake_policy(SET CMP0036 NEW)
build_name()

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,4 @@
CMake Error at CMP0036-OLD.cmake:2 \(build_name\):
build_name 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 CMP0036 OLD)
build_name()

View File

@ -0,0 +1 @@
1

View File

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

View File

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

View File

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