From 882c0f0b698e70be8b74aa498b62cb1fb22f3c24 Mon Sep 17 00:00:00 2001
From: Brad King <brad.king@kitware.com>
Date: Fri, 18 Oct 2013 11:54:09 -0400
Subject: Add infrastructure for policies that disallow commands

Add cmCommand::Disallowed helper to check the setting of a policy that
disallows the command.  Add a RunCMake.DisallowedCommands test
placeholder.  Add a Help/policy/DISALLOWED_COMMAND.txt file for
inclusion by each policy document to avoid duplication of the common
text.
---
 Help/policy/DISALLOWED_COMMAND.txt                   |  9 +++++++++
 Source/cmCommand.h                                   | 19 +++++++++++++++++++
 Tests/RunCMake/CMakeLists.txt                        |  1 +
 Tests/RunCMake/DisallowedCommands/CMakeLists.txt     |  3 +++
 Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake |  8 ++++++++
 5 files changed, 40 insertions(+)
 create mode 100644 Help/policy/DISALLOWED_COMMAND.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMakeLists.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake

diff --git a/Help/policy/DISALLOWED_COMMAND.txt b/Help/policy/DISALLOWED_COMMAND.txt
new file mode 100644
index 0000000..36280d2
--- /dev/null
+++ b/Help/policy/DISALLOWED_COMMAND.txt
@@ -0,0 +1,9 @@
+CMake >= |disallowed_version| prefer that this command never be called.
+The OLD behavior for this policy is to allow the command to be called.
+The NEW behavior for this policy is to issue a FATAL_ERROR when the
+command is called.
+
+This policy was introduced in CMake version |disallowed_version|.
+CMake version |release| warns when the policy is not set and uses
+OLD behavior.  Use the cmake_policy command to set it to OLD or
+NEW explicitly.
diff --git a/Source/cmCommand.h b/Source/cmCommand.h
index 83184a0..e148857 100644
--- a/Source/cmCommand.h
+++ b/Source/cmCommand.h
@@ -173,6 +173,25 @@ public:
     this->Error += e;
     }
 
+  /** Check if the command is disallowed by a policy.  */
+  bool Disallowed(cmPolicies::PolicyID pol, const char* e)
+    {
+    switch(this->Makefile->GetPolicyStatus(pol))
+      {
+      case cmPolicies::WARN:
+        this->Makefile->IssueMessage(cmake::AUTHOR_WARNING,
+          this->Makefile->GetPolicies()->GetPolicyWarning(pol));
+      case cmPolicies::OLD:
+        return false;
+      case cmPolicies::REQUIRED_IF_USED:
+      case cmPolicies::REQUIRED_ALWAYS:
+      case cmPolicies::NEW:
+        this->Makefile->IssueMessage(cmake::FATAL_ERROR, e);
+        break;
+      }
+    return true;
+    }
+
 protected:
   cmMakefile* Makefile;
   cmCommandArgumentsHelper Helper;
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 3a0ea91..8148cb6 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -61,6 +61,7 @@ if(UNIX AND "${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles")
   add_RunCMake_test(CompilerChange)
 endif()
 add_RunCMake_test(Configure)
+add_RunCMake_test(DisallowedCommands)
 add_RunCMake_test(ExternalData)
 add_RunCMake_test(FPHSA)
 add_RunCMake_test(GeneratorExpression)
diff --git a/Tests/RunCMake/DisallowedCommands/CMakeLists.txt b/Tests/RunCMake/DisallowedCommands/CMakeLists.txt
new file mode 100644
index 0000000..e8db6b0
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 2.8)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake b/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake
new file mode 100644
index 0000000..5f26857
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake
@@ -0,0 +1,8 @@
+include(RunCMake)
+
+foreach(p
+    )
+  run_cmake(${p}-WARN)
+  run_cmake(${p}-OLD)
+  run_cmake(${p}-NEW)
+endforeach()
-- 
cgit v0.12


From 9f64fbf5b5f128580639f14e232430194c9326f1 Mon Sep 17 00:00:00 2001
From: Brad King <brad.king@kitware.com>
Date: Fri, 18 Oct 2013 11:54:48 -0400
Subject: Add policy CMP0029 to disallow subdir_depends

---
 Help/command/subdir_depends.rst                    |  4 ++-
 Help/manual/cmake-policies.7.rst                   |  1 +
 Help/policy/CMP0029.rst                            | 10 +++++++
 Source/cmPolicies.cxx                              |  5 ++++
 Source/cmPolicies.h                                |  1 +
 Source/cmSubdirDependsCommand.cxx                  |  4 +--
 Source/cmSubdirDependsCommand.h                    | 34 ++--------------------
 .../DisallowedCommands/CMP0029-NEW-result.txt      |  1 +
 .../DisallowedCommands/CMP0029-NEW-stderr.txt      |  4 +++
 .../RunCMake/DisallowedCommands/CMP0029-NEW.cmake  |  2 ++
 .../DisallowedCommands/CMP0029-OLD-stderr.txt      |  1 +
 .../RunCMake/DisallowedCommands/CMP0029-OLD.cmake  |  2 ++
 .../DisallowedCommands/CMP0029-WARN-stderr.txt     |  7 +++++
 .../RunCMake/DisallowedCommands/CMP0029-WARN.cmake |  1 +
 .../RunCMake/DisallowedCommands/RunCMakeTest.cmake |  1 +
 15 files changed, 43 insertions(+), 35 deletions(-)
 create mode 100644 Help/policy/CMP0029.rst
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0029-NEW-result.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0029-NEW-stderr.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0029-NEW.cmake
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0029-OLD-stderr.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0029-OLD.cmake
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0029-WARN-stderr.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0029-WARN.cmake

diff --git a/Help/command/subdir_depends.rst b/Help/command/subdir_depends.rst
index c72a4af..5676c8f 100644
--- a/Help/command/subdir_depends.rst
+++ b/Help/command/subdir_depends.rst
@@ -1,7 +1,9 @@
 subdir_depends
 --------------
 
-Deprecated.  Does nothing.
+Disallowed.  See CMake Policy :policy:`CMP0029`.
+
+Does nothing.
 
 ::
 
diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst
index cb328ee..d58fabc 100644
--- a/Help/manual/cmake-policies.7.rst
+++ b/Help/manual/cmake-policies.7.rst
@@ -58,3 +58,4 @@ All Policies
    /policy/CMP0026
    /policy/CMP0027
    /policy/CMP0028
+   /policy/CMP0029
diff --git a/Help/policy/CMP0029.rst b/Help/policy/CMP0029.rst
new file mode 100644
index 0000000..92ef1ec
--- /dev/null
+++ b/Help/policy/CMP0029.rst
@@ -0,0 +1,10 @@
+CMP0029
+-------
+
+The :command:`subdir_depends` command should not be called.
+
+The implementation of this command has been empty since December 2001
+but was kept in CMake for compatibility for a long time.
+
+.. |disallowed_version| replace:: 3.0.0
+.. include:: DISALLOWED_COMMAND.txt
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index f7efc1e..fcc5bfc 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -246,6 +246,11 @@ cmPolicies::cmPolicies()
     CMP0028, "CMP0028",
     "Double colon in target name means ALIAS or IMPORTED target.",
     3,0,0,0, cmPolicies::WARN);
+
+  this->DefinePolicy(
+    CMP0029, "CMP0029",
+    "The subdir_depends command should not be called.",
+    3,0,0,0, cmPolicies::WARN);
 }
 
 cmPolicies::~cmPolicies()
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index 68cd7c2..343c01d 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -80,6 +80,7 @@ public:
     CMP0027, ///< Conditionally linked imported targets with missing include
     /// directories.
     CMP0028, ///< Double colon in target name means ALIAS or IMPORTED target.
+    CMP0029, ///< Disallow command: subdir_depends
 
     /** \brief Always the last entry.
      *
diff --git a/Source/cmSubdirDependsCommand.cxx b/Source/cmSubdirDependsCommand.cxx
index 2af7bf1..9381983 100644
--- a/Source/cmSubdirDependsCommand.cxx
+++ b/Source/cmSubdirDependsCommand.cxx
@@ -11,10 +11,10 @@
 ============================================================================*/
 #include "cmSubdirDependsCommand.h"
 
-// cmSubdirDependsCommand
 bool cmSubdirDependsCommand::InitialPass(std::vector<std::string> const& ,
                                          cmExecutionStatus &)
 {
+  this->Disallowed(cmPolicies::CMP0029,
+    "The subdir_depends command should not be called; see CMP0029.");
   return true;
 }
-
diff --git a/Source/cmSubdirDependsCommand.h b/Source/cmSubdirDependsCommand.h
index e6f1f8f..f78cfb7 100644
--- a/Source/cmSubdirDependsCommand.h
+++ b/Source/cmSubdirDependsCommand.h
@@ -14,45 +14,15 @@
 
 #include "cmCommand.h"
 
-/** \class cmSubdirDependsCommand
- * \brief Legacy command.  Do not use.
- *
- * cmSubdirDependsCommand has been left in CMake for compatability with
- * projects already using it.  Its functionality in supporting parallel
- * builds is now automatic.  The command does not do anything.
- */
 class cmSubdirDependsCommand : public cmCommand
 {
 public:
-  /**
-   * This is a virtual constructor for the command.
-   */
-  virtual cmCommand* Clone()
-    {
-    return new cmSubdirDependsCommand;
-    }
-
-  /**
-   * This is called when the command is first encountered in
-   * the CMakeLists.txt file.
-   */
+  virtual cmCommand* Clone() { return new cmSubdirDependsCommand; }
   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 "subdir_depends";}
-
-  /** This command is kept for compatibility with older CMake versions. */
-  virtual bool IsDiscouraged() const
-    {
-    return true;
-    }
-
+  virtual bool IsDiscouraged() const { return true; }
   cmTypeMacro(cmSubdirDependsCommand, cmCommand);
 };
 
-
-
 #endif
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0029-NEW-result.txt b/Tests/RunCMake/DisallowedCommands/CMP0029-NEW-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0029-NEW-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0029-NEW-stderr.txt b/Tests/RunCMake/DisallowedCommands/CMP0029-NEW-stderr.txt
new file mode 100644
index 0000000..e147081
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0029-NEW-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at CMP0029-NEW.cmake:2 \(subdir_depends\):
+  The subdir_depends command should not be called; see CMP0029.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0029-NEW.cmake b/Tests/RunCMake/DisallowedCommands/CMP0029-NEW.cmake
new file mode 100644
index 0000000..392b9d4
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0029-NEW.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0029 NEW)
+subdir_depends()
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0029-OLD-stderr.txt b/Tests/RunCMake/DisallowedCommands/CMP0029-OLD-stderr.txt
new file mode 100644
index 0000000..10f3293
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0029-OLD-stderr.txt
@@ -0,0 +1 @@
+^$
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0029-OLD.cmake b/Tests/RunCMake/DisallowedCommands/CMP0029-OLD.cmake
new file mode 100644
index 0000000..099fd90
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0029-OLD.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0029 OLD)
+subdir_depends()
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0029-WARN-stderr.txt b/Tests/RunCMake/DisallowedCommands/CMP0029-WARN-stderr.txt
new file mode 100644
index 0000000..32a452a
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0029-WARN-stderr.txt
@@ -0,0 +1,7 @@
+CMake Warning \(dev\) at CMP0029-WARN.cmake:1 \(subdir_depends\):
+  Policy CMP0029 is not set: The subdir_depends command should not be called.
+  Run "cmake --help-policy CMP0029" 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.
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0029-WARN.cmake b/Tests/RunCMake/DisallowedCommands/CMP0029-WARN.cmake
new file mode 100644
index 0000000..1ceb1f8
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0029-WARN.cmake
@@ -0,0 +1 @@
+subdir_depends()
diff --git a/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake b/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake
index 5f26857..50911ac 100644
--- a/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake
+++ b/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake
@@ -1,6 +1,7 @@
 include(RunCMake)
 
 foreach(p
+    CMP0029
     )
   run_cmake(${p}-WARN)
   run_cmake(${p}-OLD)
-- 
cgit v0.12


From 97268cf5b7626febb06d04c2201ace397a4863fd Mon Sep 17 00:00:00 2001
From: Brad King <brad.king@kitware.com>
Date: Fri, 18 Oct 2013 11:55:42 -0400
Subject: Add policy CMP0030 to disallow use_mangled_mesa

---
 Help/command/use_mangled_mesa.rst                  |  2 ++
 Help/manual/cmake-policies.7.rst                   |  1 +
 Help/policy/CMP0030.rst                            | 11 ++++++
 Source/cmPolicies.cxx                              |  5 +++
 Source/cmPolicies.h                                |  1 +
 Source/cmUseMangledMesaCommand.cxx                 |  4 ++-
 Source/cmUseMangledMesaCommand.h                   | 39 ++--------------------
 .../DisallowedCommands/CMP0030-NEW-result.txt      |  1 +
 .../DisallowedCommands/CMP0030-NEW-stderr.txt      |  4 +++
 .../RunCMake/DisallowedCommands/CMP0030-NEW.cmake  |  2 ++
 .../DisallowedCommands/CMP0030-OLD-result.txt      |  1 +
 .../DisallowedCommands/CMP0030-OLD-stderr.txt      |  4 +++
 .../RunCMake/DisallowedCommands/CMP0030-OLD.cmake  |  2 ++
 .../DisallowedCommands/CMP0030-WARN-result.txt     |  1 +
 .../DisallowedCommands/CMP0030-WARN-stderr.txt     | 12 +++++++
 .../RunCMake/DisallowedCommands/CMP0030-WARN.cmake |  1 +
 .../RunCMake/DisallowedCommands/RunCMakeTest.cmake |  1 +
 17 files changed, 54 insertions(+), 38 deletions(-)
 create mode 100644 Help/policy/CMP0030.rst
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0030-NEW-result.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0030-NEW-stderr.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0030-NEW.cmake
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0030-OLD-result.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0030-OLD-stderr.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0030-OLD.cmake
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0030-WARN-result.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0030-WARN-stderr.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0030-WARN.cmake

diff --git a/Help/command/use_mangled_mesa.rst b/Help/command/use_mangled_mesa.rst
index a4d77e9..6f4d7ac 100644
--- a/Help/command/use_mangled_mesa.rst
+++ b/Help/command/use_mangled_mesa.rst
@@ -1,6 +1,8 @@
 use_mangled_mesa
 ----------------
 
+Disallowed.  See CMake Policy :policy:`CMP0030`.
+
 Copy mesa headers for use in combination with system GL.
 
 ::
diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst
index d58fabc..c1251f0 100644
--- a/Help/manual/cmake-policies.7.rst
+++ b/Help/manual/cmake-policies.7.rst
@@ -59,3 +59,4 @@ All Policies
    /policy/CMP0027
    /policy/CMP0028
    /policy/CMP0029
+   /policy/CMP0030
diff --git a/Help/policy/CMP0030.rst b/Help/policy/CMP0030.rst
new file mode 100644
index 0000000..6fcffc3
--- /dev/null
+++ b/Help/policy/CMP0030.rst
@@ -0,0 +1,11 @@
+CMP0030
+-------
+
+The :command:`use_mangled_mesa` command should not be called.
+
+This command was created in September 2001 to support VTK before
+modern CMake language and custom command capabilities.  VTK has
+not used it in years.
+
+.. |disallowed_version| replace:: 3.0.0
+.. include:: DISALLOWED_COMMAND.txt
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index fcc5bfc..fdd3bd0 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -251,6 +251,11 @@ cmPolicies::cmPolicies()
     CMP0029, "CMP0029",
     "The subdir_depends command should not be called.",
     3,0,0,0, cmPolicies::WARN);
+
+  this->DefinePolicy(
+    CMP0030, "CMP0030",
+    "The use_mangled_mesa command should not be called.",
+    3,0,0,0, cmPolicies::WARN);
 }
 
 cmPolicies::~cmPolicies()
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index 343c01d..6de168e 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -81,6 +81,7 @@ public:
     /// directories.
     CMP0028, ///< Double colon in target name means ALIAS or IMPORTED target.
     CMP0029, ///< Disallow command: subdir_depends
+    CMP0030, ///< Disallow command: use_mangled_mesa
 
     /** \brief Always the last entry.
      *
diff --git a/Source/cmUseMangledMesaCommand.cxx b/Source/cmUseMangledMesaCommand.cxx
index 4c189e6..1bd579d 100644
--- a/Source/cmUseMangledMesaCommand.cxx
+++ b/Source/cmUseMangledMesaCommand.cxx
@@ -14,10 +14,12 @@
 
 #include <cmsys/RegularExpression.hxx>
 
-// cmUseMangledMesaCommand
 bool cmUseMangledMesaCommand
 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
 {
+  if(this->Disallowed(cmPolicies::CMP0030,
+      "The use_mangled_mesa command should not be called; see CMP0030."))
+    { return true; }
   // expected two arguments:
   // arguement one: the full path to gl_mangle.h
   // arguement two : directory for output of edited headers
diff --git a/Source/cmUseMangledMesaCommand.h b/Source/cmUseMangledMesaCommand.h
index aac7814..dca75a5 100644
--- a/Source/cmUseMangledMesaCommand.h
+++ b/Source/cmUseMangledMesaCommand.h
@@ -14,54 +14,19 @@
 
 #include "cmCommand.h"
 
-#include "cmSourceFile.h"
-
-/** \class cmUseMangledMesaCommand
- * \brief Create Tcl Wrappers for VTK classes.
- *
- * cmUseMangledMesaCommand is used to define a CMake variable include
- * path location by specifying a file and list of directories.
- */
 class cmUseMangledMesaCommand : public cmCommand
 {
 public:
   cmTypeMacro(cmUseMangledMesaCommand, cmCommand);
-
-  /**
-   * This is a virtual constructor for the command.
-   */
-  virtual cmCommand* Clone()
-    {
-    return new cmUseMangledMesaCommand;
-    }
-
-  /**
-   * This is called when the command is first encountered in
-   * the CMakeLists.txt file.
-   */
+  virtual cmCommand* Clone() { return new cmUseMangledMesaCommand; }
   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 "use_mangled_mesa";}
-
-  /**
-   * This determines if the command is invoked when in script mode.
-   */
   virtual bool IsScriptable() const { return true; }
-
-  /** This command is kept for compatibility with older CMake versions. */
-  virtual bool IsDiscouraged() const
-    {
-    return true;
-    }
-
+  virtual bool IsDiscouraged() const { return true; }
 protected:
   void CopyAndFullPathMesaHeader(const char* source,
                                  const char* outdir);
 };
 
-
 #endif
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0030-NEW-result.txt b/Tests/RunCMake/DisallowedCommands/CMP0030-NEW-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0030-NEW-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0030-NEW-stderr.txt b/Tests/RunCMake/DisallowedCommands/CMP0030-NEW-stderr.txt
new file mode 100644
index 0000000..cb380db
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0030-NEW-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at CMP0030-NEW.cmake:2 \(use_mangled_mesa\):
+  The use_mangled_mesa command should not be called; see CMP0030.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0030-NEW.cmake b/Tests/RunCMake/DisallowedCommands/CMP0030-NEW.cmake
new file mode 100644
index 0000000..73365a7
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0030-NEW.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0030 NEW)
+use_mangled_mesa()
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0030-OLD-result.txt b/Tests/RunCMake/DisallowedCommands/CMP0030-OLD-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0030-OLD-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0030-OLD-stderr.txt b/Tests/RunCMake/DisallowedCommands/CMP0030-OLD-stderr.txt
new file mode 100644
index 0000000..e95e16f
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0030-OLD-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at CMP0030-OLD.cmake:2 \(use_mangled_mesa\):
+  use_mangled_mesa called with incorrect number of arguments
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0030-OLD.cmake b/Tests/RunCMake/DisallowedCommands/CMP0030-OLD.cmake
new file mode 100644
index 0000000..efbb852
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0030-OLD.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0030 OLD)
+use_mangled_mesa()
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0030-WARN-result.txt b/Tests/RunCMake/DisallowedCommands/CMP0030-WARN-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0030-WARN-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0030-WARN-stderr.txt b/Tests/RunCMake/DisallowedCommands/CMP0030-WARN-stderr.txt
new file mode 100644
index 0000000..db3c23f13
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0030-WARN-stderr.txt
@@ -0,0 +1,12 @@
+CMake Warning \(dev\) at CMP0030-WARN.cmake:1 \(use_mangled_mesa\):
+  Policy CMP0030 is not set: The use_mangled_mesa command should not be
+  called.  Run "cmake --help-policy CMP0030" 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 CMP0030-WARN.cmake:1 \(use_mangled_mesa\):
+  use_mangled_mesa called with incorrect number of arguments
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0030-WARN.cmake b/Tests/RunCMake/DisallowedCommands/CMP0030-WARN.cmake
new file mode 100644
index 0000000..cbe0ff0
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0030-WARN.cmake
@@ -0,0 +1 @@
+use_mangled_mesa()
diff --git a/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake b/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake
index 50911ac..1945210 100644
--- a/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake
+++ b/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake
@@ -2,6 +2,7 @@ include(RunCMake)
 
 foreach(p
     CMP0029
+    CMP0030
     )
   run_cmake(${p}-WARN)
   run_cmake(${p}-OLD)
-- 
cgit v0.12


From aa76518f8bfd821f000d1779066eb7614cdd079b Mon Sep 17 00:00:00 2001
From: Brad King <brad.king@kitware.com>
Date: Fri, 18 Oct 2013 12:41:54 -0400
Subject: Add policy CMP0031 to disallow load_command

---
 Help/command/load_command.rst                      |  2 ++
 Help/manual/cmake-policies.7.rst                   |  1 +
 Help/policy/CMP0031.rst                            | 13 ++++++++++++
 Source/cmLoadCommandCommand.cxx                    |  3 +++
 Source/cmLoadCommandCommand.h                      | 24 ++--------------------
 Source/cmPolicies.cxx                              |  5 +++++
 Source/cmPolicies.h                                |  1 +
 .../DisallowedCommands/CMP0031-NEW-result.txt      |  1 +
 .../DisallowedCommands/CMP0031-NEW-stderr.txt      |  4 ++++
 .../RunCMake/DisallowedCommands/CMP0031-NEW.cmake  |  2 ++
 .../DisallowedCommands/CMP0031-OLD-result.txt      |  1 +
 .../DisallowedCommands/CMP0031-OLD-stderr.txt      |  4 ++++
 .../RunCMake/DisallowedCommands/CMP0031-OLD.cmake  |  2 ++
 .../DisallowedCommands/CMP0031-WARN-result.txt     |  1 +
 .../DisallowedCommands/CMP0031-WARN-stderr.txt     | 12 +++++++++++
 .../RunCMake/DisallowedCommands/CMP0031-WARN.cmake |  1 +
 .../RunCMake/DisallowedCommands/RunCMakeTest.cmake |  1 +
 17 files changed, 56 insertions(+), 22 deletions(-)
 create mode 100644 Help/policy/CMP0031.rst
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0031-NEW-result.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0031-NEW-stderr.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0031-NEW.cmake
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0031-OLD-result.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0031-OLD-stderr.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0031-OLD.cmake
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0031-WARN-result.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0031-WARN-stderr.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0031-WARN.cmake

diff --git a/Help/command/load_command.rst b/Help/command/load_command.rst
index 63f23be..fc316d4 100644
--- a/Help/command/load_command.rst
+++ b/Help/command/load_command.rst
@@ -1,6 +1,8 @@
 load_command
 ------------
 
+Disallowed.  See CMake Policy :policy:`CMP0031`.
+
 Load a command into a running CMake.
 
 ::
diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst
index c1251f0..ab1bf39 100644
--- a/Help/manual/cmake-policies.7.rst
+++ b/Help/manual/cmake-policies.7.rst
@@ -60,3 +60,4 @@ All Policies
    /policy/CMP0028
    /policy/CMP0029
    /policy/CMP0030
+   /policy/CMP0031
diff --git a/Help/policy/CMP0031.rst b/Help/policy/CMP0031.rst
new file mode 100644
index 0000000..e97dd0a
--- /dev/null
+++ b/Help/policy/CMP0031.rst
@@ -0,0 +1,13 @@
+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
diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx
index 84dd299..21ee0fe 100644
--- a/Source/cmLoadCommandCommand.cxx
+++ b/Source/cmLoadCommandCommand.cxx
@@ -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;
diff --git a/Source/cmLoadCommandCommand.h b/Source/cmLoadCommandCommand.h
index 918f32b..11bcf09 100644
--- a/Source/cmLoadCommandCommand.h
+++ b/Source/cmLoadCommandCommand.h
@@ -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);
 };
 
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index fdd3bd0..03e898e 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -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()
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index 6de168e..597296b 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -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.
      *
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0031-NEW-result.txt b/Tests/RunCMake/DisallowedCommands/CMP0031-NEW-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0031-NEW-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0031-NEW-stderr.txt b/Tests/RunCMake/DisallowedCommands/CMP0031-NEW-stderr.txt
new file mode 100644
index 0000000..78c2236
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0031-NEW-stderr.txt
@@ -0,0 +1,4 @@
+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\)
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0031-NEW.cmake b/Tests/RunCMake/DisallowedCommands/CMP0031-NEW.cmake
new file mode 100644
index 0000000..3d9caf2
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0031-NEW.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0031 NEW)
+load_command()
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0031-OLD-result.txt b/Tests/RunCMake/DisallowedCommands/CMP0031-OLD-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0031-OLD-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0031-OLD-stderr.txt b/Tests/RunCMake/DisallowedCommands/CMP0031-OLD-stderr.txt
new file mode 100644
index 0000000..ba198d6
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0031-OLD-stderr.txt
@@ -0,0 +1,4 @@
+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\)
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0031-OLD.cmake b/Tests/RunCMake/DisallowedCommands/CMP0031-OLD.cmake
new file mode 100644
index 0000000..8fedf98
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0031-OLD.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0031 OLD)
+load_command(bogus_command)
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0031-WARN-result.txt b/Tests/RunCMake/DisallowedCommands/CMP0031-WARN-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0031-WARN-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0031-WARN-stderr.txt b/Tests/RunCMake/DisallowedCommands/CMP0031-WARN-stderr.txt
new file mode 100644
index 0000000..4cb65b3
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0031-WARN-stderr.txt
@@ -0,0 +1,12 @@
+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\)
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0031-WARN.cmake b/Tests/RunCMake/DisallowedCommands/CMP0031-WARN.cmake
new file mode 100644
index 0000000..c9d99fc
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0031-WARN.cmake
@@ -0,0 +1 @@
+load_command(bogus_command)
diff --git a/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake b/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake
index 1945210..aea2353 100644
--- a/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake
+++ b/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake
@@ -3,6 +3,7 @@ include(RunCMake)
 foreach(p
     CMP0029
     CMP0030
+    CMP0031
     )
   run_cmake(${p}-WARN)
   run_cmake(${p}-OLD)
-- 
cgit v0.12


From 6865c8fe05d407077a598fcc0921ef62dfeaf021 Mon Sep 17 00:00:00 2001
From: Brad King <brad.king@kitware.com>
Date: Fri, 18 Oct 2013 13:00:17 -0400
Subject: Add policy CMP0032 to disallow output_required_files

---
 Help/command/output_required_files.rst             |  4 ++-
 Help/manual/cmake-policies.7.rst                   |  1 +
 Help/policy/CMP0032.rst                            | 13 +++++++++
 Source/cmOutputRequiredFilesCommand.cxx            |  3 ++
 Source/cmOutputRequiredFilesCommand.h              | 32 ++--------------------
 Source/cmPolicies.cxx                              |  5 ++++
 Source/cmPolicies.h                                |  1 +
 .../DisallowedCommands/CMP0032-NEW-result.txt      |  1 +
 .../DisallowedCommands/CMP0032-NEW-stderr.txt      |  4 +++
 .../RunCMake/DisallowedCommands/CMP0032-NEW.cmake  |  2 ++
 .../DisallowedCommands/CMP0032-OLD-result.txt      |  1 +
 .../DisallowedCommands/CMP0032-OLD-stderr.txt      |  4 +++
 .../RunCMake/DisallowedCommands/CMP0032-OLD.cmake  |  2 ++
 .../DisallowedCommands/CMP0032-WARN-result.txt     |  1 +
 .../DisallowedCommands/CMP0032-WARN-stderr.txt     | 12 ++++++++
 .../RunCMake/DisallowedCommands/CMP0032-WARN.cmake |  1 +
 .../RunCMake/DisallowedCommands/RunCMakeTest.cmake |  1 +
 17 files changed, 58 insertions(+), 30 deletions(-)
 create mode 100644 Help/policy/CMP0032.rst
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0032-NEW-result.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0032-NEW-stderr.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0032-NEW.cmake
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0032-OLD-result.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0032-OLD-stderr.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0032-OLD.cmake
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0032-WARN-result.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0032-WARN-stderr.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0032-WARN.cmake

diff --git a/Help/command/output_required_files.rst b/Help/command/output_required_files.rst
index d6bce13..5e13557 100644
--- a/Help/command/output_required_files.rst
+++ b/Help/command/output_required_files.rst
@@ -1,7 +1,9 @@
 output_required_files
 ---------------------
 
-Deprecated.  Approximate C preprocessor dependency scanning.
+Disallowed.  See CMake Policy :policy:`CMP0032`.
+
+Approximate C preprocessor dependency scanning.
 
 This command exists only because ancient CMake versions provided it.
 CMake handles preprocessor dependency scanning automatically using a
diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst
index ab1bf39..04ac33b 100644
--- a/Help/manual/cmake-policies.7.rst
+++ b/Help/manual/cmake-policies.7.rst
@@ -61,3 +61,4 @@ All Policies
    /policy/CMP0029
    /policy/CMP0030
    /policy/CMP0031
+   /policy/CMP0032
diff --git a/Help/policy/CMP0032.rst b/Help/policy/CMP0032.rst
new file mode 100644
index 0000000..1b6be48
--- /dev/null
+++ b/Help/policy/CMP0032.rst
@@ -0,0 +1,13 @@
+CMP0032
+-------
+
+The :command:`output_required_files` command should not be called.
+
+This command was added in June 2001 to expose the then-current CMake
+implicit dependency scanner.  CMake's real implicit dependency scanner
+has evolved since then but is not exposed through this command.  The
+scanning capabilities of this command are very limited and this
+functionality is better achieved through dedicated outside tools.
+
+.. |disallowed_version| replace:: 3.0.0
+.. include:: DISALLOWED_COMMAND.txt
diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx
index 01fc2cf..16b2bea 100644
--- a/Source/cmOutputRequiredFilesCommand.cxx
+++ b/Source/cmOutputRequiredFilesCommand.cxx
@@ -174,6 +174,9 @@ void cmLBDepend::DependWalk(cmDependInformation* info)
 bool cmOutputRequiredFilesCommand
 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
 {
+  if(this->Disallowed(cmPolicies::CMP0032,
+      "The output_required_files command should not be called; see CMP0032."))
+    { return true; }
   if(args.size() != 2 )
     {
     this->SetError("called with incorrect number of arguments");
diff --git a/Source/cmOutputRequiredFilesCommand.h b/Source/cmOutputRequiredFilesCommand.h
index d43b229..dd5ed6c 100644
--- a/Source/cmOutputRequiredFilesCommand.h
+++ b/Source/cmOutputRequiredFilesCommand.h
@@ -15,45 +15,19 @@
 #include "cmCommand.h"
 #include "cmMakeDepend.h"
 
-/** \class cmOutputRequiredFilesCommand
- * \brief Output a list of required files for a source file
- *
- */
 class cmOutputRequiredFilesCommand : public cmCommand
 {
 public:
-  /**
-   * This is a virtual constructor for the command.
-   */
-  virtual cmCommand* Clone()
-    {
-    return new cmOutputRequiredFilesCommand;
-    }
-
-  /**
-   * This is called when the command is first encountered in
-   * the CMakeLists.txt file.
-   */
+  cmTypeMacro(cmOutputRequiredFilesCommand, cmCommand);
+  virtual cmCommand* Clone() { return new cmOutputRequiredFilesCommand; }
   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 "output_required_files";}
+  virtual bool IsDiscouraged() const { return true; }
 
-  /** This command is kept for compatibility with older CMake versions. */
-  virtual bool IsDiscouraged() const
-    {
-    return true;
-    }
-
-
-  cmTypeMacro(cmOutputRequiredFilesCommand, cmCommand);
   void ListDependencies(cmDependInformation const *info,
                         FILE *fout,
                         std::set<cmDependInformation const*> *visited);
-
 private:
   std::string File;
   std::string OutputFile;
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index 03e898e..bf4d2c1 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -261,6 +261,11 @@ cmPolicies::cmPolicies()
     CMP0031, "CMP0031",
     "The load_command command should not be called.",
     3,0,0,0, cmPolicies::WARN);
+
+  this->DefinePolicy(
+    CMP0032, "CMP0032",
+    "The output_required_files command should not be called.",
+    3,0,0,0, cmPolicies::WARN);
 }
 
 cmPolicies::~cmPolicies()
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index 597296b..851fdb8 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -83,6 +83,7 @@ public:
     CMP0029, ///< Disallow command: subdir_depends
     CMP0030, ///< Disallow command: use_mangled_mesa
     CMP0031, ///< Disallow command: load_command
+    CMP0032, ///< Disallow command: output_required_files
 
     /** \brief Always the last entry.
      *
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0032-NEW-result.txt b/Tests/RunCMake/DisallowedCommands/CMP0032-NEW-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0032-NEW-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0032-NEW-stderr.txt b/Tests/RunCMake/DisallowedCommands/CMP0032-NEW-stderr.txt
new file mode 100644
index 0000000..c7ac16e
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0032-NEW-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at CMP0032-NEW.cmake:2 \(output_required_files\):
+  The output_required_files command should not be called; see CMP0032.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0032-NEW.cmake b/Tests/RunCMake/DisallowedCommands/CMP0032-NEW.cmake
new file mode 100644
index 0000000..c6fb5e8
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0032-NEW.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0032 NEW)
+output_required_files()
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0032-OLD-result.txt b/Tests/RunCMake/DisallowedCommands/CMP0032-OLD-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0032-OLD-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0032-OLD-stderr.txt b/Tests/RunCMake/DisallowedCommands/CMP0032-OLD-stderr.txt
new file mode 100644
index 0000000..2223c42
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0032-OLD-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at CMP0032-OLD.cmake:2 \(output_required_files\):
+  output_required_files called with incorrect number of arguments
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0032-OLD.cmake b/Tests/RunCMake/DisallowedCommands/CMP0032-OLD.cmake
new file mode 100644
index 0000000..6585110
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0032-OLD.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0032 OLD)
+output_required_files()
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0032-WARN-result.txt b/Tests/RunCMake/DisallowedCommands/CMP0032-WARN-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0032-WARN-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0032-WARN-stderr.txt b/Tests/RunCMake/DisallowedCommands/CMP0032-WARN-stderr.txt
new file mode 100644
index 0000000..0cf3f94
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0032-WARN-stderr.txt
@@ -0,0 +1,12 @@
+CMake Warning \(dev\) at CMP0032-WARN.cmake:1 \(output_required_files\):
+  Policy CMP0032 is not set: The output_required_files command should not be
+  called.  Run "cmake --help-policy CMP0032" 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 CMP0032-WARN.cmake:1 \(output_required_files\):
+  output_required_files called with incorrect number of arguments
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0032-WARN.cmake b/Tests/RunCMake/DisallowedCommands/CMP0032-WARN.cmake
new file mode 100644
index 0000000..7411e48
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0032-WARN.cmake
@@ -0,0 +1 @@
+output_required_files()
diff --git a/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake b/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake
index aea2353..3d54d8f 100644
--- a/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake
+++ b/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake
@@ -4,6 +4,7 @@ foreach(p
     CMP0029
     CMP0030
     CMP0031
+    CMP0032
     )
   run_cmake(${p}-WARN)
   run_cmake(${p}-OLD)
-- 
cgit v0.12


From 248d1dc057564dc00e3374d7797a1e42ea57032d Mon Sep 17 00:00:00 2001
From: Brad King <brad.king@kitware.com>
Date: Fri, 18 Oct 2013 13:09:32 -0400
Subject: Add policy CMP0033 to disallow export_library_dependencies

---
 Help/command/export_library_dependencies.rst       |  4 ++-
 Help/manual/cmake-policies.7.rst                   |  1 +
 Help/policy/CMP0033.rst                            | 14 ++++++++
 Source/cmExportLibraryDependencies.cxx             |  4 +++
 Source/cmExportLibraryDependencies.h               | 39 +++-------------------
 Source/cmPolicies.cxx                              |  5 +++
 Source/cmPolicies.h                                |  1 +
 .../DisallowedCommands/CMP0033-NEW-result.txt      |  1 +
 .../DisallowedCommands/CMP0033-NEW-stderr.txt      |  4 +++
 .../RunCMake/DisallowedCommands/CMP0033-NEW.cmake  |  2 ++
 .../DisallowedCommands/CMP0033-OLD-result.txt      |  1 +
 .../DisallowedCommands/CMP0033-OLD-stderr.txt      |  4 +++
 .../RunCMake/DisallowedCommands/CMP0033-OLD.cmake  |  2 ++
 .../DisallowedCommands/CMP0033-WARN-result.txt     |  1 +
 .../DisallowedCommands/CMP0033-WARN-stderr.txt     | 12 +++++++
 .../RunCMake/DisallowedCommands/CMP0033-WARN.cmake |  1 +
 .../RunCMake/DisallowedCommands/RunCMakeTest.cmake |  1 +
 17 files changed, 61 insertions(+), 36 deletions(-)
 create mode 100644 Help/policy/CMP0033.rst
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0033-NEW-result.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0033-NEW-stderr.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0033-NEW.cmake
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0033-OLD-result.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0033-OLD-stderr.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0033-OLD.cmake
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0033-WARN-result.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0033-WARN-stderr.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0033-WARN.cmake

diff --git a/Help/command/export_library_dependencies.rst b/Help/command/export_library_dependencies.rst
index c09f3d5..73c0b42 100644
--- a/Help/command/export_library_dependencies.rst
+++ b/Help/command/export_library_dependencies.rst
@@ -1,7 +1,9 @@
 export_library_dependencies
 ---------------------------
 
-Deprecated.  Use INSTALL(EXPORT) or EXPORT command.
+Disallowed.  See CMake Policy :policy:`CMP0033`.
+
+Use :command:`install(EXPORT)` or :command:`export` command.
 
 This command generates an old-style library dependencies file.
 Projects requiring CMake 2.6 or later should not use the command.  Use
diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst
index 04ac33b..062a75d 100644
--- a/Help/manual/cmake-policies.7.rst
+++ b/Help/manual/cmake-policies.7.rst
@@ -62,3 +62,4 @@ All Policies
    /policy/CMP0030
    /policy/CMP0031
    /policy/CMP0032
+   /policy/CMP0033
diff --git a/Help/policy/CMP0033.rst b/Help/policy/CMP0033.rst
new file mode 100644
index 0000000..677e1c4
--- /dev/null
+++ b/Help/policy/CMP0033.rst
@@ -0,0 +1,14 @@
+CMP0033
+-------
+
+The :command:`export_library_dependencies` command should not be called.
+
+This command was added in January 2003 to export ``<tgt>_LIB_DEPENDS``
+internal CMake cache entries to a file for installation with a project.
+This was used at the time to allow transitive link dependencies to
+work for applications outside of the original build tree of a project.
+The functionality has been superseded by the :command:`export` and
+:command:`install(EXPORT)` commands.
+
+.. |disallowed_version| replace:: 3.0.0
+.. include:: DISALLOWED_COMMAND.txt
diff --git a/Source/cmExportLibraryDependencies.cxx b/Source/cmExportLibraryDependencies.cxx
index e3b1626..064ffa3 100644
--- a/Source/cmExportLibraryDependencies.cxx
+++ b/Source/cmExportLibraryDependencies.cxx
@@ -21,6 +21,10 @@
 bool cmExportLibraryDependenciesCommand
 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
 {
+  if(this->Disallowed(cmPolicies::CMP0033,
+      "The export_library_dependencies command should not be called; "
+      "see CMP0033."))
+    { return true; }
   if(args.size() < 1 )
     {
     this->SetError("called with incorrect number of arguments");
diff --git a/Source/cmExportLibraryDependencies.h b/Source/cmExportLibraryDependencies.h
index a384a7c..29b568f 100644
--- a/Source/cmExportLibraryDependencies.h
+++ b/Source/cmExportLibraryDependencies.h
@@ -14,50 +14,19 @@
 
 #include "cmCommand.h"
 
-/** \class cmExportLibraryDependenciesCommand
- * \brief Add a test to the lists of tests to run.
- *
- * cmExportLibraryDependenciesCommand adds a test to the list of tests to run
- *
- */
 class cmExportLibraryDependenciesCommand : public cmCommand
 {
 public:
-  /**
-   * This is a virtual constructor for the command.
-   */
-  virtual cmCommand* Clone()
-    {
-    return new cmExportLibraryDependenciesCommand;
-    }
-
-  /**
-   * This is called when the command is first encountered in
-   * the CMakeLists.txt file.
-   */
+  cmTypeMacro(cmExportLibraryDependenciesCommand, cmCommand);
+  virtual cmCommand* Clone() { return new cmExportLibraryDependenciesCommand; }
   virtual bool InitialPass(std::vector<std::string> const& args,
                            cmExecutionStatus &status);
+  virtual const char* GetName() const { return "export_library_dependencies";}
+  virtual bool IsDiscouraged() const { return true; }
 
-  /**
-   * This is called at the end after all the information
-   * specified by the command is accumulated.
-   */
   virtual void FinalPass();
   virtual bool HasFinalPass() const { return true; }
 
-  /**
-   * The name of the command as specified in CMakeList.txt.
-   */
-  virtual const char* GetName() const { return "export_library_dependencies";}
-
-  /** This command is kept for compatibility with older CMake versions. */
-  virtual bool IsDiscouraged() const
-    {
-    return true;
-    }
-
-  cmTypeMacro(cmExportLibraryDependenciesCommand, cmCommand);
-
 private:
   std::string Filename;
   bool Append;
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index bf4d2c1..7852d9a 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -266,6 +266,11 @@ cmPolicies::cmPolicies()
     CMP0032, "CMP0032",
     "The output_required_files command should not be called.",
     3,0,0,0, cmPolicies::WARN);
+
+  this->DefinePolicy(
+    CMP0033, "CMP0033",
+    "The export_library_dependencies command should not be called.",
+    3,0,0,0, cmPolicies::WARN);
 }
 
 cmPolicies::~cmPolicies()
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index 851fdb8..99982c4 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -84,6 +84,7 @@ public:
     CMP0030, ///< Disallow command: use_mangled_mesa
     CMP0031, ///< Disallow command: load_command
     CMP0032, ///< Disallow command: output_required_files
+    CMP0033, ///< Disallow command: export_library_dependencies
 
     /** \brief Always the last entry.
      *
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0033-NEW-result.txt b/Tests/RunCMake/DisallowedCommands/CMP0033-NEW-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0033-NEW-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0033-NEW-stderr.txt b/Tests/RunCMake/DisallowedCommands/CMP0033-NEW-stderr.txt
new file mode 100644
index 0000000..8d210aa
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0033-NEW-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at CMP0033-NEW.cmake:2 \(export_library_dependencies\):
+  The export_library_dependencies command should not be called; see CMP0033.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0033-NEW.cmake b/Tests/RunCMake/DisallowedCommands/CMP0033-NEW.cmake
new file mode 100644
index 0000000..6f90f29
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0033-NEW.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0033 NEW)
+export_library_dependencies()
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0033-OLD-result.txt b/Tests/RunCMake/DisallowedCommands/CMP0033-OLD-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0033-OLD-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0033-OLD-stderr.txt b/Tests/RunCMake/DisallowedCommands/CMP0033-OLD-stderr.txt
new file mode 100644
index 0000000..e5dd2dd
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0033-OLD-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at CMP0033-OLD.cmake:2 \(export_library_dependencies\):
+  export_library_dependencies called with incorrect number of arguments
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0033-OLD.cmake b/Tests/RunCMake/DisallowedCommands/CMP0033-OLD.cmake
new file mode 100644
index 0000000..a3504b6
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0033-OLD.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0033 OLD)
+export_library_dependencies()
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0033-WARN-result.txt b/Tests/RunCMake/DisallowedCommands/CMP0033-WARN-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0033-WARN-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0033-WARN-stderr.txt b/Tests/RunCMake/DisallowedCommands/CMP0033-WARN-stderr.txt
new file mode 100644
index 0000000..e561dac
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0033-WARN-stderr.txt
@@ -0,0 +1,12 @@
+CMake Warning \(dev\) at CMP0033-WARN.cmake:1 \(export_library_dependencies\):
+  Policy CMP0033 is not set: The export_library_dependencies command should
+  not be called.  Run "cmake --help-policy CMP0033" 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 CMP0033-WARN.cmake:1 \(export_library_dependencies\):
+  export_library_dependencies called with incorrect number of arguments
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0033-WARN.cmake b/Tests/RunCMake/DisallowedCommands/CMP0033-WARN.cmake
new file mode 100644
index 0000000..f897ddd
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0033-WARN.cmake
@@ -0,0 +1 @@
+export_library_dependencies()
diff --git a/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake b/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake
index 3d54d8f..003298a 100644
--- a/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake
+++ b/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake
@@ -5,6 +5,7 @@ foreach(p
     CMP0030
     CMP0031
     CMP0032
+    CMP0033
     )
   run_cmake(${p}-WARN)
   run_cmake(${p}-OLD)
-- 
cgit v0.12


From 178b9af18674b23be97758236c676c9bd9398c40 Mon Sep 17 00:00:00 2001
From: Brad King <brad.king@kitware.com>
Date: Mon, 21 Oct 2013 11:50:47 -0400
Subject: Add policy CMP0034 to disallow utility_source

---
 Help/command/utility_source.rst                    |  2 ++
 Help/manual/cmake-policies.7.rst                   |  1 +
 Help/policy/CMP0034.rst                            | 11 ++++++
 Source/cmPolicies.cxx                              |  5 +++
 Source/cmPolicies.h                                |  1 +
 Source/cmUtilitySourceCommand.cxx                  |  3 ++
 Source/cmUtilitySourceCommand.h                    | 39 ++--------------------
 .../DisallowedCommands/CMP0034-NEW-result.txt      |  1 +
 .../DisallowedCommands/CMP0034-NEW-stderr.txt      |  4 +++
 .../RunCMake/DisallowedCommands/CMP0034-NEW.cmake  |  2 ++
 .../DisallowedCommands/CMP0034-OLD-result.txt      |  1 +
 .../DisallowedCommands/CMP0034-OLD-stderr.txt      |  4 +++
 .../RunCMake/DisallowedCommands/CMP0034-OLD.cmake  |  2 ++
 .../DisallowedCommands/CMP0034-WARN-result.txt     |  1 +
 .../DisallowedCommands/CMP0034-WARN-stderr.txt     | 12 +++++++
 .../RunCMake/DisallowedCommands/CMP0034-WARN.cmake |  1 +
 .../RunCMake/DisallowedCommands/RunCMakeTest.cmake |  1 +
 17 files changed, 55 insertions(+), 36 deletions(-)
 create mode 100644 Help/policy/CMP0034.rst
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0034-NEW-result.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0034-NEW-stderr.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0034-NEW.cmake
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0034-OLD-result.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0034-OLD-stderr.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0034-OLD.cmake
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0034-WARN-result.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0034-WARN-stderr.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0034-WARN.cmake

diff --git a/Help/command/utility_source.rst b/Help/command/utility_source.rst
index e513627..5122e52 100644
--- a/Help/command/utility_source.rst
+++ b/Help/command/utility_source.rst
@@ -1,6 +1,8 @@
 utility_source
 --------------
 
+Disallowed.  See CMake Policy :policy:`CMP0034`.
+
 Specify the source tree of a third-party utility.
 
 ::
diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst
index 062a75d..0e9d346 100644
--- a/Help/manual/cmake-policies.7.rst
+++ b/Help/manual/cmake-policies.7.rst
@@ -63,3 +63,4 @@ All Policies
    /policy/CMP0031
    /policy/CMP0032
    /policy/CMP0033
+   /policy/CMP0034
diff --git a/Help/policy/CMP0034.rst b/Help/policy/CMP0034.rst
new file mode 100644
index 0000000..1dd6e5c
--- /dev/null
+++ b/Help/policy/CMP0034.rst
@@ -0,0 +1,11 @@
+CMP0034
+-------
+
+The :command:`utility_source` command should not be called.
+
+This command was introduced in March 2001 to help build executables used to
+generate other files.  This approach has long been replaced by
+:command:`add_executable` combined with :command:`add_custom_command`.
+
+.. |disallowed_version| replace:: 3.0.0
+.. include:: DISALLOWED_COMMAND.txt
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index 7852d9a..f830806 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -271,6 +271,11 @@ cmPolicies::cmPolicies()
     CMP0033, "CMP0033",
     "The export_library_dependencies command should not be called.",
     3,0,0,0, cmPolicies::WARN);
+
+  this->DefinePolicy(
+    CMP0034, "CMP0034",
+    "The utility_source command should not be called.",
+    3,0,0,0, cmPolicies::WARN);
 }
 
 cmPolicies::~cmPolicies()
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index 99982c4..ae1ccc1 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -85,6 +85,7 @@ public:
     CMP0031, ///< Disallow command: load_command
     CMP0032, ///< Disallow command: output_required_files
     CMP0033, ///< Disallow command: export_library_dependencies
+    CMP0034, ///< Disallow command: utility_source
 
     /** \brief Always the last entry.
      *
diff --git a/Source/cmUtilitySourceCommand.cxx b/Source/cmUtilitySourceCommand.cxx
index 6ea3dfa..11e5108 100644
--- a/Source/cmUtilitySourceCommand.cxx
+++ b/Source/cmUtilitySourceCommand.cxx
@@ -15,6 +15,9 @@
 bool cmUtilitySourceCommand
 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
 {
+  if(this->Disallowed(cmPolicies::CMP0034,
+      "The utility_source command should not be called; see CMP0034."))
+    { return true; }
   if(args.size() < 3)
     {
     this->SetError("called with incorrect number of arguments");
diff --git a/Source/cmUtilitySourceCommand.h b/Source/cmUtilitySourceCommand.h
index 0a0653c..83d115c 100644
--- a/Source/cmUtilitySourceCommand.h
+++ b/Source/cmUtilitySourceCommand.h
@@ -14,48 +14,15 @@
 
 #include "cmCommand.h"
 
-/** \class cmUtilitySourceCommand
- * \brief A command to setup a cache entry with the location of a third-party
- * utility's source.
- *
- * cmUtilitySourceCommand is used when a third-party utility's source is
- * included in the project's source tree.  It specifies the location of
- * the executable's source, and any files that may be needed to confirm the
- * identity of the source.
- */
 class cmUtilitySourceCommand : public cmCommand
 {
 public:
-  /**
-   * This is a virtual constructor for the command.
-   */
-  virtual cmCommand* Clone()
-    {
-    return new cmUtilitySourceCommand;
-    }
-
-  /**
-   * This is called when the command is first encountered in
-   * the CMakeLists.txt file.
-   */
+  cmTypeMacro(cmUtilitySourceCommand, cmCommand);
+  virtual cmCommand* Clone() { return new cmUtilitySourceCommand; }
   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 "utility_source";}
-
-  /** This command is kept for compatibility with older CMake versions. */
-  virtual bool IsDiscouraged() const
-    {
-    return true;
-    }
-
-
-  cmTypeMacro(cmUtilitySourceCommand, cmCommand);
+  virtual bool IsDiscouraged() const { return true; }
 };
 
-
-
 #endif
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0034-NEW-result.txt b/Tests/RunCMake/DisallowedCommands/CMP0034-NEW-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0034-NEW-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0034-NEW-stderr.txt b/Tests/RunCMake/DisallowedCommands/CMP0034-NEW-stderr.txt
new file mode 100644
index 0000000..1dd279b
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0034-NEW-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at CMP0034-NEW.cmake:2 \(utility_source\):
+  The utility_source command should not be called; see CMP0034.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0034-NEW.cmake b/Tests/RunCMake/DisallowedCommands/CMP0034-NEW.cmake
new file mode 100644
index 0000000..48724a9
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0034-NEW.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0034 NEW)
+utility_source()
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0034-OLD-result.txt b/Tests/RunCMake/DisallowedCommands/CMP0034-OLD-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0034-OLD-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0034-OLD-stderr.txt b/Tests/RunCMake/DisallowedCommands/CMP0034-OLD-stderr.txt
new file mode 100644
index 0000000..3358628
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0034-OLD-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at CMP0034-OLD.cmake:2 \(utility_source\):
+  utility_source called with incorrect number of arguments
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0034-OLD.cmake b/Tests/RunCMake/DisallowedCommands/CMP0034-OLD.cmake
new file mode 100644
index 0000000..a2c9798
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0034-OLD.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0034 OLD)
+utility_source()
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0034-WARN-result.txt b/Tests/RunCMake/DisallowedCommands/CMP0034-WARN-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0034-WARN-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0034-WARN-stderr.txt b/Tests/RunCMake/DisallowedCommands/CMP0034-WARN-stderr.txt
new file mode 100644
index 0000000..ea3831f
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0034-WARN-stderr.txt
@@ -0,0 +1,12 @@
+CMake Warning \(dev\) at CMP0034-WARN.cmake:1 \(utility_source\):
+  Policy CMP0034 is not set: The utility_source command should not be called.
+  Run "cmake --help-policy CMP0034" 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 CMP0034-WARN.cmake:1 \(utility_source\):
+  utility_source called with incorrect number of arguments
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0034-WARN.cmake b/Tests/RunCMake/DisallowedCommands/CMP0034-WARN.cmake
new file mode 100644
index 0000000..b4ae045
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0034-WARN.cmake
@@ -0,0 +1 @@
+utility_source()
diff --git a/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake b/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake
index 003298a..0bd8591 100644
--- a/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake
+++ b/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake
@@ -6,6 +6,7 @@ foreach(p
     CMP0031
     CMP0032
     CMP0033
+    CMP0034
     )
   run_cmake(${p}-WARN)
   run_cmake(${p}-OLD)
-- 
cgit v0.12


From 3969bb23aafcdbd2174649e8eeb8f7b0e7ea6c4c Mon Sep 17 00:00:00 2001
From: Brad King <brad.king@kitware.com>
Date: Mon, 21 Oct 2013 11:58:48 -0400
Subject: Add policy CMP0035 to disallow variable_requires

---
 Help/command/variable_requires.rst                 |  4 ++-
 Help/manual/cmake-policies.7.rst                   |  1 +
 Help/policy/CMP0035.rst                            | 10 +++++++
 Source/cmPolicies.cxx                              |  5 ++++
 Source/cmPolicies.h                                |  1 +
 Source/cmVariableRequiresCommand.cxx               |  3 +++
 Source/cmVariableRequiresCommand.h                 | 31 +++-------------------
 .../DisallowedCommands/CMP0035-NEW-result.txt      |  1 +
 .../DisallowedCommands/CMP0035-NEW-stderr.txt      |  4 +++
 .../RunCMake/DisallowedCommands/CMP0035-NEW.cmake  |  2 ++
 .../DisallowedCommands/CMP0035-OLD-result.txt      |  1 +
 .../DisallowedCommands/CMP0035-OLD-stderr.txt      |  4 +++
 .../RunCMake/DisallowedCommands/CMP0035-OLD.cmake  |  2 ++
 .../DisallowedCommands/CMP0035-WARN-result.txt     |  1 +
 .../DisallowedCommands/CMP0035-WARN-stderr.txt     | 12 +++++++++
 .../RunCMake/DisallowedCommands/CMP0035-WARN.cmake |  1 +
 .../RunCMake/DisallowedCommands/RunCMakeTest.cmake |  1 +
 17 files changed, 55 insertions(+), 29 deletions(-)
 create mode 100644 Help/policy/CMP0035.rst
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0035-NEW-result.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0035-NEW-stderr.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0035-NEW.cmake
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0035-OLD-result.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0035-OLD-stderr.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0035-OLD.cmake
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0035-WARN-result.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0035-WARN-stderr.txt
 create mode 100644 Tests/RunCMake/DisallowedCommands/CMP0035-WARN.cmake

diff --git a/Help/command/variable_requires.rst b/Help/command/variable_requires.rst
index 7535e40..831dd00 100644
--- a/Help/command/variable_requires.rst
+++ b/Help/command/variable_requires.rst
@@ -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.
 
diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst
index 0e9d346..3161cf0 100644
--- a/Help/manual/cmake-policies.7.rst
+++ b/Help/manual/cmake-policies.7.rst
@@ -64,3 +64,4 @@ All Policies
    /policy/CMP0032
    /policy/CMP0033
    /policy/CMP0034
+   /policy/CMP0035
diff --git a/Help/policy/CMP0035.rst b/Help/policy/CMP0035.rst
new file mode 100644
index 0000000..ebdaccc
--- /dev/null
+++ b/Help/policy/CMP0035.rst
@@ -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
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index f830806..aad088b 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -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()
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index ae1ccc1..29ff1e3 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -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.
      *
diff --git a/Source/cmVariableRequiresCommand.cxx b/Source/cmVariableRequiresCommand.cxx
index 747e9be..ddb4003 100644
--- a/Source/cmVariableRequiresCommand.cxx
+++ b/Source/cmVariableRequiresCommand.cxx
@@ -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");
diff --git a/Source/cmVariableRequiresCommand.h b/Source/cmVariableRequiresCommand.h
index 1032745..881b149 100644
--- a/Source/cmVariableRequiresCommand.h
+++ b/Source/cmVariableRequiresCommand.h
@@ -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; }
 };
 
 
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0035-NEW-result.txt b/Tests/RunCMake/DisallowedCommands/CMP0035-NEW-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0035-NEW-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0035-NEW-stderr.txt b/Tests/RunCMake/DisallowedCommands/CMP0035-NEW-stderr.txt
new file mode 100644
index 0000000..0604829
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0035-NEW-stderr.txt
@@ -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\)
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0035-NEW.cmake b/Tests/RunCMake/DisallowedCommands/CMP0035-NEW.cmake
new file mode 100644
index 0000000..27eb32e
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0035-NEW.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0035 NEW)
+variable_requires()
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0035-OLD-result.txt b/Tests/RunCMake/DisallowedCommands/CMP0035-OLD-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0035-OLD-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0035-OLD-stderr.txt b/Tests/RunCMake/DisallowedCommands/CMP0035-OLD-stderr.txt
new file mode 100644
index 0000000..86eda43
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0035-OLD-stderr.txt
@@ -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\)
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0035-OLD.cmake b/Tests/RunCMake/DisallowedCommands/CMP0035-OLD.cmake
new file mode 100644
index 0000000..7425262
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0035-OLD.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0035 OLD)
+variable_requires()
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0035-WARN-result.txt b/Tests/RunCMake/DisallowedCommands/CMP0035-WARN-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0035-WARN-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0035-WARN-stderr.txt b/Tests/RunCMake/DisallowedCommands/CMP0035-WARN-stderr.txt
new file mode 100644
index 0000000..4d4fc8e
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0035-WARN-stderr.txt
@@ -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\)
diff --git a/Tests/RunCMake/DisallowedCommands/CMP0035-WARN.cmake b/Tests/RunCMake/DisallowedCommands/CMP0035-WARN.cmake
new file mode 100644
index 0000000..3af4de1
--- /dev/null
+++ b/Tests/RunCMake/DisallowedCommands/CMP0035-WARN.cmake
@@ -0,0 +1 @@
+variable_requires()
diff --git a/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake b/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake
index 0bd8591..3211fd3 100644
--- a/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake
+++ b/Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake
@@ -7,6 +7,7 @@ foreach(p
     CMP0032
     CMP0033
     CMP0034
+    CMP0035
     )
   run_cmake(${p}-WARN)
   run_cmake(${p}-OLD)
-- 
cgit v0.12


From 6c9194488aa5d61774ffeb40f54149ce2255f00c Mon Sep 17 00:00:00 2001
From: Brad King <brad.king@kitware.com>
Date: Mon, 21 Oct 2013 13:12:18 -0400
Subject: 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 +++
 .../RunCMake/DisallowedCommands/CMP0036-NEW.cmake  |  2 ++
 .../DisallowedCommands/CMP0036-OLD-result.txt      |  1 +
 .../DisallowedCommands/CMP0036-OLD-stderr.txt      |  4 +++
 .../RunCMake/DisallowedCommands/CMP0036-OLD.cmake  |  2 ++
 .../DisallowedCommands/CMP0036-WARN-result.txt     |  1 +
 .../DisallowedCommands/CMP0036-WARN-stderr.txt     | 12 +++++++
 .../RunCMake/DisallowedCommands/CMP0036-WARN.cmake |  1 +
 .../RunCMake/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 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)
-- 
cgit v0.12