diff options
author | Brad King <brad.king@kitware.com> | 2013-10-21 17:12:18 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2013-10-22 13:09:53 (GMT) |
commit | 6c9194488aa5d61774ffeb40f54149ce2255f00c (patch) | |
tree | fc1200e03d64e3a83893de34814d3c244cfb6d54 | |
parent | 3969bb23aafcdbd2174649e8eeb8f7b0e7ea6c4c (diff) | |
download | CMake-6c9194488aa5d61774ffeb40f54149ce2255f00c.zip CMake-6c9194488aa5d61774ffeb40f54149ce2255f00c.tar.gz CMake-6c9194488aa5d61774ffeb40f54149ce2255f00c.tar.bz2 |
Add policy CMP0036 to disallow build_name
-rw-r--r-- | Help/command/build_name.rst | 4 | ||||
-rw-r--r-- | Help/manual/cmake-policies.7.rst | 1 | ||||
-rw-r--r-- | Help/policy/CMP0036.rst | 12 | ||||
-rw-r--r-- | Source/cmBuildNameCommand.cxx | 3 | ||||
-rw-r--r-- | Source/cmBuildNameCommand.h | 38 | ||||
-rw-r--r-- | Source/cmPolicies.cxx | 5 | ||||
-rw-r--r-- | Source/cmPolicies.h | 1 | ||||
-rw-r--r-- | Tests/RunCMake/DisallowedCommands/CMP0036-NEW-result.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/DisallowedCommands/CMP0036-NEW-stderr.txt | 4 | ||||
-rw-r--r-- | Tests/RunCMake/DisallowedCommands/CMP0036-NEW.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/DisallowedCommands/CMP0036-OLD-result.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/DisallowedCommands/CMP0036-OLD-stderr.txt | 4 | ||||
-rw-r--r-- | Tests/RunCMake/DisallowedCommands/CMP0036-OLD.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/DisallowedCommands/CMP0036-WARN-result.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/DisallowedCommands/CMP0036-WARN-stderr.txt | 12 | ||||
-rw-r--r-- | Tests/RunCMake/DisallowedCommands/CMP0036-WARN.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake | 1 |
17 files changed, 58 insertions, 35 deletions
diff --git a/Help/command/build_name.rst b/Help/command/build_name.rst index 2148e49..53cd05e 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 3161cf0..fcbccba 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 0000000..9a5a0fd --- /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_<LANG>_COMPILER` variables. + +.. |disallowed_version| replace:: 3.0.0 +.. include:: DISALLOWED_COMMAND.txt diff --git a/Source/cmBuildNameCommand.cxx b/Source/cmBuildNameCommand.cxx index f95a79e..e3528e1 100644 --- a/Source/cmBuildNameCommand.cxx +++ b/Source/cmBuildNameCommand.cxx @@ -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"); diff --git a/Source/cmBuildNameCommand.h b/Source/cmBuildNameCommand.h index faeb3c0..2f7acde 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<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; } }; diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index aad088b..c05de17 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 29ff1e3..9e72bdc 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 0000000..d00491f --- /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 0000000..11aabd0 --- /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 0000000..5341db2 --- /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 0000000..d00491f --- /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 0000000..fef195f --- /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 0000000..fdd840f --- /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 0000000..d00491f --- /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 0000000..b9b7c5a --- /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 0000000..9556687 --- /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 3211fd3..208ea20 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) |