فهرست منبع

CMakeDetermineVSServicePack: Add policy to remove this module

It has been documented as deprecated since CMake 3.0.
Brad King 4 ماه پیش
والد
کامیت
39da33ae81

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

@@ -98,6 +98,7 @@ Policies Introduced by CMake 4.1
 .. toctree::
    :maxdepth: 1
 
+   CMP0196: The CMakeDetermineVSServicePack module is removed. </policy/CMP0196>
    CMP0195: Swift modules in build trees use the Swift module directory structure. </policy/CMP0195>
    CMP0194: MSVC is not an assembler for language ASM. </policy/CMP0194>
    CMP0193: GNUInstallDirs caches CMAKE_INSTALL_* with leading 'usr/' for install prefix '/'. </policy/CMP0193>

+ 23 - 0
Help/policy/CMP0196.rst

@@ -0,0 +1,23 @@
+CMP0196
+-------
+
+.. versionadded:: 4.1
+
+The :module:`CMakeDetermineVSServicePack` module is removed.
+
+The ``CMakeDetermineVSServicePack`` module has long been superseded by
+the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable, and the module
+has been documented as deprecated since CMake 3.0.  CMake 4.1 and above
+prefer to not provide the module.  This policy provides compatibility
+for projects that have not been ported away from it.
+
+The ``OLD`` behavior of this policy is for
+``include(CMakeDetermineVSServicePack)`` to load the deprecated module.
+The ``NEW`` behavior halts with a fatal error if anything tries to include
+the module.
+
+.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 4.1
+.. |WARNS_OR_DOES_NOT_WARN| replace:: warns
+.. include:: include/STANDARD_ADVICE.rst
+
+.. include:: include/DEPRECATED.rst

+ 6 - 0
Help/release/dev/remove-CMakeDetermineVSServicePack.rst

@@ -0,0 +1,6 @@
+remove-CMakeDetermineVSServicePack
+----------------------------------
+
+* The :module`:CMakeDetermineVSServicePack` module has been deprecated
+  via policy :policy:`CMP0196`.  Port projects to the
+  :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable instead.

+ 14 - 0
Modules/CMakeDetermineVSServicePack.cmake

@@ -5,6 +5,10 @@
 CMakeDetermineVSServicePack
 ---------------------------
 
+.. versionchanged:: 4.1
+
+  This module is available only if policy :policy:`CMP0196` is not set to ``NEW``.
+
 .. deprecated:: 3.0
 
   This module should no longer be used.  The functionality of this module has
@@ -59,6 +63,16 @@ Determining the Visual Studio service pack version in a project:
   endif()
 #]=======================================================================]
 
+cmake_policy(GET CMP0196 _CMakeDetermineVSServicePack_CMP0196)
+if(_CMakeDetermineVSServicePack_CMP0196 STREQUAL "NEW")
+  message(FATAL_ERROR "The CMakeDetermineVSServicePack module has been removed by policy CMP0196.")
+endif()
+
+if(_CMakeDetermineVSServicePack_testing)
+  set(_CMakeDetermineVSServicePack_included TRUE)
+  return()
+endif()
+
 if(NOT CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.8)
   message(DEPRECATION
     "This module is deprecated and should not be used.  "

+ 1 - 0
Source/cmIncludeCommand.cxx

@@ -19,6 +19,7 @@ bool cmIncludeCommand(std::vector<std::string> const& args,
 {
   static std::map<std::string, cmPolicies::PolicyID> DeprecatedModules;
   if (DeprecatedModules.empty()) {
+    DeprecatedModules["CMakeDetermineVSServicePack"] = cmPolicies::CMP0196;
     DeprecatedModules["CMakeFindFrameworks"] = cmPolicies::CMP0173;
     DeprecatedModules["Dart"] = cmPolicies::CMP0145;
     DeprecatedModules["Documentation"] = cmPolicies::CMP0106;

+ 3 - 1
Source/cmPolicies.h

@@ -584,7 +584,9 @@ class cmMakefile;
   SELECT(                                                                     \
     POLICY, CMP0195,                                                          \
     "Swift modules in build trees use the Swift module directory structure.", \
-    4, 1, 0, WARN)
+    4, 1, 0, WARN)                                                            \
+  SELECT(POLICY, CMP0196,                                                     \
+         "The CMakeDetermineVSServicePack 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)                                         \

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

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

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

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

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

@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0196 NEW)
+include(CMakeDetermineVSServicePack)

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

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

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

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

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

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

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

@@ -0,0 +1,7 @@
+cmake_policy(SET CMP0196 OLD)
+set(_CMakeDetermineVSServicePack_testing 1)
+include(CMakeDetermineVSServicePack)
+
+if(NOT _CMakeDetermineVSServicePack_included)
+  message(FATAL_ERROR "CMakeDetermineVSServicePack.cmake not included")
+endif()

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

@@ -0,0 +1,8 @@
+^CMake Warning \(dev\) at CMP0196-WARN\.cmake:[0-9]+ \(include\):
+  Policy CMP0196 is not set: The CMakeDetermineVSServicePack module is
+  removed\.  Run "cmake --help-policy CMP0196" 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/CMP0196-WARN.cmake

@@ -0,0 +1,7 @@
+# Do not set CMP0196.
+set(_CMakeDetermineVSServicePack_testing 1)
+include(CMakeDetermineVSServicePack)
+
+if(NOT _CMakeDetermineVSServicePack_included)
+  message(FATAL_ERROR "CMakeDetermineVSServicePack.cmake not included")
+endif()

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

@@ -38,3 +38,8 @@ run_cmake(CMP0191-OLD)
 run_cmake(CMP0191-WARN)
 run_cmake(CMP0191-NEW-name)
 run_cmake(CMP0191-NEW-path)
+
+run_cmake(CMP0196-OLD)
+run_cmake(CMP0196-WARN)
+run_cmake(CMP0196-NEW-name)
+run_cmake(CMP0196-NEW-path)