From 6c9194488aa5d61774ffeb40f54149ce2255f00c Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 21 Oct 2013 13:12:18 -0400 Subject: [PATCH] Add policy CMP0036 to disallow build_name --- Help/command/build_name.rst | 4 +- Help/manual/cmake-policies.7.rst | 1 + Help/policy/CMP0036.rst | 12 ++++++ Source/cmBuildNameCommand.cxx | 3 ++ Source/cmBuildNameCommand.h | 38 ++----------------- Source/cmPolicies.cxx | 5 +++ Source/cmPolicies.h | 1 + .../DisallowedCommands/CMP0036-NEW-result.txt | 1 + .../DisallowedCommands/CMP0036-NEW-stderr.txt | 4 ++ .../DisallowedCommands/CMP0036-NEW.cmake | 2 + .../DisallowedCommands/CMP0036-OLD-result.txt | 1 + .../DisallowedCommands/CMP0036-OLD-stderr.txt | 4 ++ .../DisallowedCommands/CMP0036-OLD.cmake | 2 + .../CMP0036-WARN-result.txt | 1 + .../CMP0036-WARN-stderr.txt | 12 ++++++ .../DisallowedCommands/CMP0036-WARN.cmake | 1 + .../DisallowedCommands/RunCMakeTest.cmake | 1 + 17 files changed, 58 insertions(+), 35 deletions(-) create mode 100644 Help/policy/CMP0036.rst create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0036-NEW-result.txt create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0036-NEW-stderr.txt create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0036-NEW.cmake create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0036-OLD-result.txt create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0036-OLD-stderr.txt create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0036-OLD.cmake create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0036-WARN-result.txt create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0036-WARN-stderr.txt create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0036-WARN.cmake diff --git a/Help/command/build_name.rst b/Help/command/build_name.rst index 2148e491f..53cd05ec1 100644 --- a/Help/command/build_name.rst +++ b/Help/command/build_name.rst @@ -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. :: diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index 3161cf0a3..fcbccbaea 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -65,3 +65,4 @@ All Policies /policy/CMP0033 /policy/CMP0034 /policy/CMP0035 + /policy/CMP0036 diff --git a/Help/policy/CMP0036.rst b/Help/policy/CMP0036.rst new file mode 100644 index 000000000..9a5a0fdaf --- /dev/null +++ b/Help/policy/CMP0036.rst @@ -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__COMPILER` variables. + +.. |disallowed_version| replace:: 3.0.0 +.. include:: DISALLOWED_COMMAND.txt diff --git a/Source/cmBuildNameCommand.cxx b/Source/cmBuildNameCommand.cxx index f95a79eda..e3528e136 100644 --- a/Source/cmBuildNameCommand.cxx +++ b/Source/cmBuildNameCommand.cxx @@ -17,6 +17,9 @@ bool cmBuildNameCommand ::InitialPass(std::vector 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"); diff --git a/Source/cmBuildNameCommand.h b/Source/cmBuildNameCommand.h index faeb3c0eb..2f7acdeb7 100644 --- a/Source/cmBuildNameCommand.h +++ b/Source/cmBuildNameCommand.h @@ -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 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; } }; diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index aad088bfe..c05de174c 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -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() diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 29ff1e3da..9e72bdc9b 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -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. * diff --git a/Tests/RunCMake/DisallowedCommands/CMP0036-NEW-result.txt b/Tests/RunCMake/DisallowedCommands/CMP0036-NEW-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/DisallowedCommands/CMP0036-NEW-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/DisallowedCommands/CMP0036-NEW-stderr.txt b/Tests/RunCMake/DisallowedCommands/CMP0036-NEW-stderr.txt new file mode 100644 index 000000000..11aabd098 --- /dev/null +++ b/Tests/RunCMake/DisallowedCommands/CMP0036-NEW-stderr.txt @@ -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\) diff --git a/Tests/RunCMake/DisallowedCommands/CMP0036-NEW.cmake b/Tests/RunCMake/DisallowedCommands/CMP0036-NEW.cmake new file mode 100644 index 000000000..5341db2a0 --- /dev/null +++ b/Tests/RunCMake/DisallowedCommands/CMP0036-NEW.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0036 NEW) +build_name() diff --git a/Tests/RunCMake/DisallowedCommands/CMP0036-OLD-result.txt b/Tests/RunCMake/DisallowedCommands/CMP0036-OLD-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/DisallowedCommands/CMP0036-OLD-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/DisallowedCommands/CMP0036-OLD-stderr.txt b/Tests/RunCMake/DisallowedCommands/CMP0036-OLD-stderr.txt new file mode 100644 index 000000000..fef195f40 --- /dev/null +++ b/Tests/RunCMake/DisallowedCommands/CMP0036-OLD-stderr.txt @@ -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\) diff --git a/Tests/RunCMake/DisallowedCommands/CMP0036-OLD.cmake b/Tests/RunCMake/DisallowedCommands/CMP0036-OLD.cmake new file mode 100644 index 000000000..fdd840f94 --- /dev/null +++ b/Tests/RunCMake/DisallowedCommands/CMP0036-OLD.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0036 OLD) +build_name() diff --git a/Tests/RunCMake/DisallowedCommands/CMP0036-WARN-result.txt b/Tests/RunCMake/DisallowedCommands/CMP0036-WARN-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/DisallowedCommands/CMP0036-WARN-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/DisallowedCommands/CMP0036-WARN-stderr.txt b/Tests/RunCMake/DisallowedCommands/CMP0036-WARN-stderr.txt new file mode 100644 index 000000000..b9b7c5a9c --- /dev/null +++ b/Tests/RunCMake/DisallowedCommands/CMP0036-WARN-stderr.txt @@ -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\) diff --git a/Tests/RunCMake/DisallowedCommands/CMP0036-WARN.cmake b/Tests/RunCMake/DisallowedCommands/CMP0036-WARN.cmake new file mode 100644 index 000000000..9556687ab --- /dev/null +++ b/Tests/RunCMake/DisallowedCommands/CMP0036-WARN.cmake @@ -0,0 +1 @@ +build_name() diff --git a/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake b/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake index 3211fd37a..208ea2085 100644 --- a/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake +++ b/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake @@ -8,6 +8,7 @@ foreach(p CMP0033 CMP0034 CMP0035 + CMP0036 ) run_cmake(${p}-WARN) run_cmake(${p}-OLD)