Browse Source

Remove compatibility with CMake versions older than 3.0

This compatibility has been deprecated since commit 3a4791548d
(Deprecate compatibility with CMake versions older than 3.5, 2023-02-09,
v3.27.0-rc1~508^2).  The behavior itself has been deprecated
since CMake 3.0.

Issue: #26613
Brad King 1 year ago
parent
commit
8e0a0291ef

+ 2 - 2
Help/command/DEPRECATED_POLICY_VERSIONS.txt

@@ -1,9 +1,9 @@
 .. versionchanged:: 4.0
 
-  Compatibility with versions of CMake older than 2.8.12 is removed.
+  Compatibility with versions of CMake older than 3.0 is removed.
   Calls to :command:`cmake_minimum_required(VERSION)` or
   :command:`cmake_policy(VERSION)` that do not specify at least
-  2.8.12 as their policy version (optionally via ``...<max>``)
+  3.0 as their policy version (optionally via ``...<max>``)
   will produce an error in CMake 4.0 and above.
 
 .. versionchanged:: 3.31

+ 1 - 1
Help/release/dev/remove-old-compatibility.rst

@@ -1,7 +1,7 @@
 remove-old-compatibility
 ------------------------
 
-* Compatibility with versions of CMake older than 2.8.12 has been removed.
+* Compatibility with versions of CMake older than 3.0 has been removed.
   Calls to :command:`cmake_minimum_required` or :command:`cmake_policy`
   that set the policy version to an older value now issue an error.
   Note that calls to those commands can still support older versions of

+ 1 - 1
Source/cmMakefile.cxx

@@ -1604,7 +1604,7 @@ void cmMakefile::Configure()
         this->SetCheckCMP0000(true);
 
         // Implicitly set the version for the user.
-        cmPolicies::ApplyPolicyVersion(this, 2, 8, 12,
+        cmPolicies::ApplyPolicyVersion(this, 3, 0, 0,
                                        cmPolicies::WarnCompat::Off);
       }
     }

+ 6 - 8
Source/cmPolicies.cxx

@@ -295,23 +295,21 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf, unsigned int majorVer,
                                     WarnCompat warnCompat)
 {
   // Error on policy versions for which support has been removed.
-  if (majorVer < 2 ||
-      (majorVer == 2 && (minorVer < 8 || (minorVer == 8 && patchVer < 12)))) {
+  if (majorVer < 3) {
     if (IsFromLegacyInstallEXPORT(mf, majorVer, minorVer, patchVer)) {
       // Silently tolerate cmake_policy calls generated by install(EXPORT)
       // in CMake versions prior to 3.18.
-      majorVer = 2;
-      minorVer = 8;
-      patchVer = 12;
+      majorVer = 3;
+      minorVer = 0;
+      patchVer = 0;
     } else {
       mf->IssueMessage(MessageType::FATAL_ERROR,
-                       "Compatibility with CMake < 2.8.12 has been removed "
+                       "Compatibility with CMake < 3.0 has been removed "
                        "from CMake.\n" ADVICE_UPDATE_VERSION_ARGUMENT);
       cmSystemTools::SetFatalErrorOccurred();
       return false;
     }
-  } else if ((majorVer < 3 || (majorVer == 3 && minorVer < 10)) &&
-             warnCompat == WarnCompat::On) {
+  } else if (majorVer == 3 && minorVer < 10 && warnCompat == WarnCompat::On) {
     // Warn about policy versions for which support will be removed.
     mf->IssueMessage(
       MessageType::DEPRECATION_WARNING,

+ 1 - 1
Tests/RunCMake/cmake_minimum_required/BeforeVersionRemoved-stderr.txt

@@ -1,5 +1,5 @@
 ^CMake Error at BeforeVersionRemoved\.cmake:1 \(cmake_minimum_required\):
-  Compatibility with CMake < 2\.8\.12 has been removed from CMake\.
+  Compatibility with CMake < 3\.0 has been removed from CMake\.
 
   Update the VERSION argument <min> value\.  Or, use the <min>\.\.\.<max> syntax
   to tell CMake that the project requires at least <min> but has been updated

+ 1 - 1
Tests/RunCMake/cmake_minimum_required/BeforeVersionRemoved.cmake

@@ -1 +1 @@
-cmake_minimum_required(VERSION 2.8.11)
+cmake_minimum_required(VERSION 2.8.12)

+ 1 - 1
Tests/RunCMake/cmake_minimum_required/PolicyBeforeVersionRemoved-stderr.txt

@@ -1,5 +1,5 @@
 ^CMake Error at PolicyBeforeVersionRemoved\.cmake:1 \(cmake_policy\):
-  Compatibility with CMake < 2\.8\.12 has been removed from CMake\.
+  Compatibility with CMake < 3\.0 has been removed from CMake\.
 
   Update the VERSION argument <min> value\.  Or, use the <min>\.\.\.<max> syntax
   to tell CMake that the project requires at least <min> but has been updated

+ 1 - 1
Tests/RunCMake/cmake_minimum_required/PolicyBeforeVersionRemoved.cmake

@@ -1 +1 @@
-cmake_policy(VERSION 2.8.11)
+cmake_policy(VERSION 2.8.12)