Просмотр исходного кода

Add policy CMP0030 to disallow use_mangled_mesa

Brad King 12 лет назад
Родитель
Сommit
97268cf5b7

+ 2 - 0
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.
 
 ::

+ 1 - 0
Help/manual/cmake-policies.7.rst

@@ -59,3 +59,4 @@ All Policies
    /policy/CMP0027
    /policy/CMP0028
    /policy/CMP0029
+   /policy/CMP0030

+ 11 - 0
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

+ 5 - 0
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()

+ 1 - 0
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.
      *

+ 3 - 1
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

+ 2 - 37
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

+ 1 - 0
Tests/RunCMake/DisallowedCommands/CMP0030-NEW-result.txt

@@ -0,0 +1 @@
+1

+ 4 - 0
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\)

+ 2 - 0
Tests/RunCMake/DisallowedCommands/CMP0030-NEW.cmake

@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0030 NEW)
+use_mangled_mesa()

+ 1 - 0
Tests/RunCMake/DisallowedCommands/CMP0030-OLD-result.txt

@@ -0,0 +1 @@
+1

+ 4 - 0
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\)$

+ 2 - 0
Tests/RunCMake/DisallowedCommands/CMP0030-OLD.cmake

@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0030 OLD)
+use_mangled_mesa()

+ 1 - 0
Tests/RunCMake/DisallowedCommands/CMP0030-WARN-result.txt

@@ -0,0 +1 @@
+1

+ 12 - 0
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\)

+ 1 - 0
Tests/RunCMake/DisallowedCommands/CMP0030-WARN.cmake

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

+ 1 - 0
Tests/RunCMake/DisallowedCommands/RunCMakeTest.cmake

@@ -2,6 +2,7 @@ include(RunCMake)
 
 foreach(p
     CMP0029
+    CMP0030
     )
   run_cmake(${p}-WARN)
   run_cmake(${p}-OLD)