Browse Source

FindGCCXML: Add policy to remove this module

GCC-XML has been superseded by CastXML for a long time.

Closes: #26687
Brad King 10 months ago
parent
commit
2123244746

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

@@ -98,6 +98,7 @@ Policies Introduced by CMake 4.1
 .. toctree::
    :maxdepth: 1
 
+   CMP0188: The FindGCCXML module is removed. </policy/CMP0188>
    CMP0187: Include source file without an extension after the same name with an extension. </policy/CMP0187>
    CMP0186: Regular expressions match ^ at most once in repeated searches. </policy/CMP0186>
 

+ 21 - 0
Help/policy/CMP0188.rst

@@ -0,0 +1,21 @@
+CMP0188
+-------
+
+.. versionadded:: 4.1
+
+The :module:`FindGCCXML` module is removed.
+
+CMake 4.0 and below provide the :module:`FindGCCXML` module, but the GCC-XML
+tool has long been superseded by CastXML.  CMake 4.1 and above prefer to not
+provide the :module:`FindGCCXML` module.  This policy provides compatibility
+for projects that have not been ported away from it.
+
+The ``OLD`` behavior of this policy is for ``find_package(GCCXML)`` to load
+the deprecated module.  The ``NEW`` behavior is for ``find_package(GCCXML)``
+to fail as if the module does not exist.
+
+.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 4.1
+.. |WARNS_OR_DOES_NOT_WARN| replace:: warns
+.. include:: STANDARD_ADVICE.txt
+
+.. include:: DEPRECATED.txt

+ 5 - 0
Help/release/dev/remove-FindGCCXML.rst

@@ -0,0 +1,5 @@
+remove-FindGCCXML
+-----------------
+
+* The :module:`FindGCCXML` module has been deprecated via policy
+  :policy:`CMP0188`.  Port projects to CastXML instead.

+ 16 - 5
Modules/FindGCCXML.cmake

@@ -5,17 +5,28 @@
 FindGCCXML
 ----------
 
-Find the GCC-XML front-end executable.
-
+.. versionchanged:: 4.1
+  This module is available only if policy :policy:`CMP0188` is not set to ``NEW``.
+  Port projects to search for CastXML by calling ``find_program`` directly.
 
+Find the GCC-XML front-end executable.
 
 This module will define the following variables:
 
-::
-
-  GCCXML - the GCC-XML front-end executable.
+``GCCXML``
+  The GCC-XML front-end executable.
 #]=======================================================================]
 
+cmake_policy(GET CMP0188 _FindGCCXML_CMP0188)
+if(_FindGCCXML_CMP0188 STREQUAL "NEW")
+  message(FATAL_ERROR "The FindGCCXML module has been removed by policy CMP0188.")
+endif()
+
+if(_FindGCCXML_testing)
+  set(_FindGCCXML_included TRUE)
+  return()
+endif()
+
 find_program(GCCXML
   NAMES gccxml
         ../GCC_XML/gccxml

+ 1 - 0
Source/cmFindPackageCommand.cxx

@@ -532,6 +532,7 @@ cmFindPackageCommand::cmFindPackageCommand(cmExecutionStatus& status)
   this->DeprecatedFindModules["Boost"] = cmPolicies::CMP0167;
   this->DeprecatedFindModules["CUDA"] = cmPolicies::CMP0146;
   this->DeprecatedFindModules["Dart"] = cmPolicies::CMP0145;
+  this->DeprecatedFindModules["GCCXML"] = cmPolicies::CMP0188;
   this->DeprecatedFindModules["PythonInterp"] = cmPolicies::CMP0148;
   this->DeprecatedFindModules["PythonLibs"] = cmPolicies::CMP0148;
   this->DeprecatedFindModules["Qt"] = cmPolicies::CMP0084;

+ 1 - 0
Source/cmIncludeCommand.cxx

@@ -25,6 +25,7 @@ bool cmIncludeCommand(std::vector<std::string> const& args,
     DeprecatedModules["FindBoost"] = cmPolicies::CMP0167;
     DeprecatedModules["FindCUDA"] = cmPolicies::CMP0146;
     DeprecatedModules["FindDart"] = cmPolicies::CMP0145;
+    DeprecatedModules["FindGCCXML"] = cmPolicies::CMP0188;
     DeprecatedModules["FindPythonInterp"] = cmPolicies::CMP0148;
     DeprecatedModules["FindPythonLibs"] = cmPolicies::CMP0148;
     DeprecatedModules["WriteCompilerDetectionHeader"] = cmPolicies::CMP0120;

+ 2 - 1
Source/cmPolicies.h

@@ -562,7 +562,8 @@ class cmMakefile;
   SELECT(POLICY, CMP0187,                                                     \
          "Include source file without an extension after the same name with " \
          "an extension.",                                                     \
-         4, 1, 0, WARN)
+         4, 1, 0, WARN)                                                       \
+  SELECT(POLICY, CMP0188, "The FindGCCXML module is removed.", 4, 1, 0, WARN)
 
 #define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
 #define CM_FOR_EACH_POLICY_ID(POLICY)                                         \

+ 4 - 0
Tests/RunCMake/find_package/CMP0188-NEW-stderr.txt

@@ -0,0 +1,4 @@
+^CMake Warning at CMP0188-NEW\.cmake:[0-9]+ \(find_package\):
+  No "FindGCCXML\.cmake" found in CMAKE_MODULE_PATH\.
+Call Stack \(most recent call first\):
+  CMakeLists\.txt:[0-9]+ \(include\)

+ 7 - 0
Tests/RunCMake/find_package/CMP0188-NEW.cmake

@@ -0,0 +1,7 @@
+cmake_policy(SET CMP0188 NEW)
+set(_FindGCCXML_testing TRUE)
+find_package(GCCXML MODULE)
+
+if(_FindGCCXML_included)
+  message(FATAL_ERROR "FindGCCXML.cmake erroneously included")
+endif()

+ 7 - 0
Tests/RunCMake/find_package/CMP0188-OLD.cmake

@@ -0,0 +1,7 @@
+cmake_policy(SET CMP0188 OLD)
+set(_FindGCCXML_testing TRUE)
+find_package(GCCXML MODULE)
+
+if(NOT _FindGCCXML_included)
+  message(FATAL_ERROR "FindGCCXML.cmake not included")
+endif()

+ 8 - 0
Tests/RunCMake/find_package/CMP0188-WARN-stderr.txt

@@ -0,0 +1,8 @@
+CMake Warning \(dev\) at CMP0188-WARN\.cmake:[0-9]+ \(find_package\):
+  Policy CMP0188 is not set: The FindGCCXML module is removed\.  Run "cmake
+  --help-policy CMP0188" for policy details\.  Use the cmake_policy command to
+  set the policy and suppress this warning\.
+
+Call Stack \(most recent call first\):
+  CMakeLists\.txt:[0-9]+ \(include\)
+This warning is for project developers\.  Use -Wno-dev to suppress it\.$

+ 6 - 0
Tests/RunCMake/find_package/CMP0188-WARN.cmake

@@ -0,0 +1,6 @@
+set(_FindGCCXML_testing TRUE)
+find_package(GCCXML MODULE)
+
+if(NOT _FindGCCXML_included)
+  message(FATAL_ERROR "FindGCCXML.cmake not included")
+endif()

+ 3 - 0
Tests/RunCMake/find_package/RunCMakeTest.cmake

@@ -57,6 +57,9 @@ run_cmake(CMP0148-Libs-NEW)
 run_cmake(CMP0167-OLD)
 run_cmake(CMP0167-WARN)
 run_cmake(CMP0167-NEW)
+run_cmake(CMP0188-OLD)
+run_cmake(CMP0188-WARN)
+run_cmake(CMP0188-NEW)
 run_cmake(WrongVersionRange)
 run_cmake(EmptyVersionRange)
 run_cmake(VersionRangeWithEXACT)

+ 1 - 0
Tests/RunCMake/include/CMP0188-NEW-name-result.txt

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

+ 6 - 0
Tests/RunCMake/include/CMP0188-NEW-name-stderr.txt

@@ -0,0 +1,6 @@
+^CMake Error at CMP0188-NEW-name\.cmake:[0-9]+ \(include\):
+  include could not find requested file:
+
+    FindGCCXML
+Call Stack \(most recent call first\):
+  CMakeLists\.txt:[0-9]+ \(include\)$

+ 2 - 0
Tests/RunCMake/include/CMP0188-NEW-name.cmake

@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0188 NEW)
+include(FindGCCXML)

+ 1 - 0
Tests/RunCMake/include/CMP0188-NEW-path-result.txt

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

+ 6 - 0
Tests/RunCMake/include/CMP0188-NEW-path-stderr.txt

@@ -0,0 +1,6 @@
+^CMake Error at [^
+]*/Modules/FindGCCXML.cmake:[0-9]+ \(message\):
+  The FindGCCXML module has been removed by policy CMP0188\.
+Call Stack \(most recent call first\):
+  CMP0188-NEW-path\.cmake:[0-9]+ \(include\)
+  CMakeLists\.txt:[0-9]+ \(include\)$

+ 2 - 0
Tests/RunCMake/include/CMP0188-NEW-path.cmake

@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0188 NEW)
+include(${CMAKE_ROOT}/Modules/FindGCCXML.cmake)

+ 7 - 0
Tests/RunCMake/include/CMP0188-OLD.cmake

@@ -0,0 +1,7 @@
+cmake_policy(SET CMP0188 OLD)
+set(_FindGCCXML_testing 1)
+include(FindGCCXML)
+
+if(NOT _FindGCCXML_included)
+  message(FATAL_ERROR "FindGCCXML.cmake not included")
+endif()

+ 8 - 0
Tests/RunCMake/include/CMP0188-WARN-stderr.txt

@@ -0,0 +1,8 @@
+^CMake Warning \(dev\) at CMP0188-WARN\.cmake:[0-9]+ \(include\):
+  Policy CMP0188 is not set: The FindGCCXML module is removed\.  Run "cmake
+  --help-policy CMP0188" for policy details\.  Use the cmake_policy command to
+  set the policy and suppress this warning\.
+
+Call Stack \(most recent call first\):
+  CMakeLists\.txt:[0-9]+ \(include\)
+This warning is for project developers\.  Use -Wno-dev to suppress it\.$

+ 7 - 0
Tests/RunCMake/include/CMP0188-WARN.cmake

@@ -0,0 +1,7 @@
+# Do not set CMP0188.
+set(_FindGCCXML_testing 1)
+include(FindGCCXML)
+
+if(NOT _FindGCCXML_included)
+  message(FATAL_ERROR "FindGCCXML.cmake not included")
+endif()

+ 5 - 0
Tests/RunCMake/include/RunCMakeTest.cmake

@@ -25,3 +25,8 @@ run_cmake(CMP0167-OLD)
 run_cmake(CMP0167-WARN)
 run_cmake(CMP0167-NEW-name)
 run_cmake(CMP0167-NEW-path)
+
+run_cmake(CMP0188-OLD)
+run_cmake(CMP0188-WARN)
+run_cmake(CMP0188-NEW-name)
+run_cmake(CMP0188-NEW-path)