From 03a215643db16866dfa87b0edb4fc3accbda5b2e Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 6 Nov 2024 15:21:52 -0500 Subject: [PATCH] CMP0001: Remove support for OLD behavior --- Help/policy/CMP0001.rst | 11 +-- .../CMAKE_BACKWARDS_COMPATIBILITY.rst | 2 +- Source/cmCMakePolicyCommand.cxx | 17 ----- Source/cmLocalGenerator.cxx | 70 ++----------------- Source/cmLocalGenerator.h | 22 ------ Source/cmPolicies.cxx | 17 ----- Source/cmPolicies.h | 2 +- Source/cmake.cxx | 21 ------ 8 files changed, 14 insertions(+), 148 deletions(-) diff --git a/Help/policy/CMP0001.rst b/Help/policy/CMP0001.rst index e06f2a156b..3a3c4424af 100644 --- a/Help/policy/CMP0001.rst +++ b/Help/policy/CMP0001.rst @@ -1,11 +1,14 @@ CMP0001 ------- +.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0 +.. include:: REMOVED_PROLOGUE.txt + ``CMAKE_BACKWARDS_COMPATIBILITY`` should no longer be used. The behavior is to check ``CMAKE_BACKWARDS_COMPATIBILITY`` and present it to the user. The ``NEW`` behavior is to ignore -CMAKE_BACKWARDS_COMPATIBILITY completely. +``CMAKE_BACKWARDS_COMPATIBILITY`` completely. In CMake 2.4 and below the variable ``CMAKE_BACKWARDS_COMPATIBILITY`` was used to request compatibility with earlier versions of CMake. In @@ -15,7 +18,5 @@ and the :command:`cmake_policy` command. However, CMake must still check below. .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 2.6.0 -.. |WARNS_OR_DOES_NOT_WARN| replace:: warns -.. include:: STANDARD_ADVICE.txt - -.. include:: DEPRECATED.txt +.. |WARNED_OR_DID_NOT_WARN| replace:: warned +.. include:: REMOVED_EPILOGUE.txt diff --git a/Help/variable/CMAKE_BACKWARDS_COMPATIBILITY.rst b/Help/variable/CMAKE_BACKWARDS_COMPATIBILITY.rst index 05c366a950..7e9959829c 100644 --- a/Help/variable/CMAKE_BACKWARDS_COMPATIBILITY.rst +++ b/Help/variable/CMAKE_BACKWARDS_COMPATIBILITY.rst @@ -1,4 +1,4 @@ CMAKE_BACKWARDS_COMPATIBILITY ----------------------------- -Deprecated. See CMake Policy :policy:`CMP0001` documentation. +Removed. See policy :policy:`CMP0001`. diff --git a/Source/cmCMakePolicyCommand.cxx b/Source/cmCMakePolicyCommand.cxx index 9035254efd..81050e694b 100644 --- a/Source/cmCMakePolicyCommand.cxx +++ b/Source/cmCMakePolicyCommand.cxx @@ -5,10 +5,7 @@ #include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmPolicies.h" -#include "cmState.h" -#include "cmStateTypes.h" #include "cmStringAlgorithms.h" -#include "cmValue.h" namespace { bool HandleSetMode(std::vector const& args, @@ -88,20 +85,6 @@ bool HandleSetMode(std::vector const& args, status.SetError("SET failed to set policy."); return false; } - if (args[1] == "CMP0001" && - (policyStatus == cmPolicies::WARN || policyStatus == cmPolicies::OLD)) { - if (!(status.GetMakefile().GetState()->GetInitializedCacheValue( - "CMAKE_BACKWARDS_COMPATIBILITY"))) { - // Set it to 2.4 because that is the last version where the - // variable had meaning. - status.GetMakefile().AddCacheDefinition( - "CMAKE_BACKWARDS_COMPATIBILITY", "2.4", - "For backwards compatibility, what version of CMake " - "commands and " - "syntax should this version of CMake try to support.", - cmStateEnums::STRING); - } - } return true; } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 1f30e9fbaf..f2a65da1c1 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -58,7 +58,6 @@ #include "cmTarget.h" #include "cmTestGenerator.h" #include "cmValue.h" -#include "cmVersion.h" #include "cmake.h" #if defined(__HAIKU__) @@ -102,8 +101,6 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, cmMakefile* makefile) this->AliasTargets = makefile->GetAliasTargets(); this->EmitUniversalBinaryFlags = true; - this->BackwardsCompatibility = 0; - this->BackwardsCompatibilityFinal = false; this->ComputeObjectMaxPath(); @@ -4327,15 +4324,12 @@ std::string cmLocalGenerator::GetObjectFileNameWithoutTarget( bool keptSourceExtension = true; if (!source.GetPropertyAsBool("KEEP_EXTENSION")) { // Decide whether this language wants to replace the source - // extension with the object extension. For CMake 2.4 - // compatibility do this by default. - bool replaceExt = this->NeedBackwardsCompatibility_2_4(); - if (!replaceExt) { - std::string lang = source.GetLanguage(); - if (!lang.empty()) { - replaceExt = this->Makefile->IsOn( - cmStrCat("CMAKE_", lang, "_OUTPUT_EXTENSION_REPLACE")); - } + // extension with the object extension. + bool replaceExt = false; + std::string lang = source.GetLanguage(); + if (!lang.empty()) { + replaceExt = this->Makefile->IsOn( + cmStrCat("CMAKE_", lang, "_OUTPUT_EXTENSION_REPLACE")); } // Remove the source extension if it is to be replaced. @@ -4400,58 +4394,6 @@ std::string cmLocalGenerator::GetTargetDirectory( return ""; } -KWIML_INT_uint64_t cmLocalGenerator::GetBackwardsCompatibility() -{ - // The computed version may change until the project is fully - // configured. - if (!this->BackwardsCompatibilityFinal) { - unsigned int major = 0; - unsigned int minor = 0; - unsigned int patch = 0; - if (cmValue value = - this->Makefile->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY")) { - switch (sscanf(value->c_str(), "%u.%u.%u", &major, &minor, &patch)) { - case 2: - patch = 0; - break; - case 1: - minor = 0; - patch = 0; - break; - default: - break; - } - } - this->BackwardsCompatibility = CMake_VERSION_ENCODE(major, minor, patch); - this->BackwardsCompatibilityFinal = true; - } - - return this->BackwardsCompatibility; -} - -bool cmLocalGenerator::NeedBackwardsCompatibility_2_4() -{ - // Check the policy to decide whether to pay attention to this - // variable. - switch (this->GetPolicyStatus(cmPolicies::CMP0001)) { - case cmPolicies::WARN: - // WARN is just OLD without warning because user code does not - // always affect whether this check is done. - CM_FALLTHROUGH; - case cmPolicies::OLD: - // Old behavior is to check the variable. - break; - case cmPolicies::NEW: - // New behavior is to ignore the variable. - return false; - } - - // Compatibility is needed if CMAKE_BACKWARDS_COMPATIBILITY is set - // equal to or lower than the given version. - KWIML_INT_uint64_t actual_compat = this->GetBackwardsCompatibility(); - return (actual_compat && actual_compat <= CMake_VERSION_ENCODE(2, 4, 255)); -} - cmPolicies::PolicyStatus cmLocalGenerator::GetPolicyStatus( cmPolicies::PolicyID id) const { diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index ec4240fc53..f51b298e5e 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -16,8 +16,6 @@ #include -#include - #include "cmCustomCommandTypes.h" #include "cmGeneratorOptions.h" #include "cmGeneratorTarget.h" @@ -433,23 +431,6 @@ public: virtual std::string GetTargetDirectory( cmGeneratorTarget const* target) const; - /** - * Get the level of backwards compatibility requested by the project - * in this directory. This is the value of the CMake variable - * CMAKE_BACKWARDS_COMPATIBILITY whose format is - * "major.minor[.patch]". The returned integer is encoded as - * - * CMake_VERSION_ENCODE(major, minor, patch) - * - * and is monotonically increasing with the CMake version. - */ - KWIML_INT_uint64_t GetBackwardsCompatibility(); - - /** - * Test whether compatibility is set to a given version or lower. - */ - bool NeedBackwardsCompatibility_2_4(); - cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id) const; cmake* GetCMakeInstance() const; @@ -617,9 +598,6 @@ protected: bool EmitUniversalBinaryFlags; - KWIML_INT_uint64_t BackwardsCompatibility; - bool BackwardsCompatibilityFinal; - private: /** * See LinearGetSourceFileWithOutput for background information diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index fa64029104..5407715f67 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -12,12 +12,9 @@ #include "cmListFileCache.h" #include "cmMakefile.h" #include "cmMessageType.h" -#include "cmState.h" #include "cmStateSnapshot.h" -#include "cmStateTypes.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -#include "cmValue.h" #include "cmVersion.h" static bool stringToId(const char* input, cmPolicies::PolicyID& pid) @@ -322,20 +319,6 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf, unsigned int majorVer, !mf->SetPolicy(pid, status)) { return false; } - if (pid == cmPolicies::CMP0001 && - (status == cmPolicies::WARN || status == cmPolicies::OLD)) { - if (!(mf->GetState()->GetInitializedCacheValue( - "CMAKE_BACKWARDS_COMPATIBILITY"))) { - // Set it to 2.4 because that is the last version where the - // variable had meaning. - mf->AddCacheDefinition( - "CMAKE_BACKWARDS_COMPATIBILITY", "2.4", - "For backwards compatibility, what version of CMake " - "commands and " - "syntax should this version of CMake try to support.", - cmStateEnums::STRING); - } - } } } else { if (!mf->SetPolicy(pid, cmPolicies::NEW)) { diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index c1294ff978..46e65b90d6 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -18,7 +18,7 @@ class cmMakefile; "A minimum required CMake version must be specified.", 2, 6, 0, NEW) \ SELECT(POLICY, CMP0001, \ "CMAKE_BACKWARDS_COMPATIBILITY should no longer be used.", 2, 6, 0, \ - WARN) \ + NEW) \ SELECT(POLICY, CMP0002, "Logical target names must be globally unique.", 2, \ 6, 0, WARN) \ SELECT( \ diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 95f4a929d6..5e9192b649 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2650,27 +2650,6 @@ int cmake::ActualConfigure() // if the project did not define one of the entries below, add them now // so users can edit the values in the cache: - // We used to always present LIBRARY_OUTPUT_PATH and - // EXECUTABLE_OUTPUT_PATH. They are now documented as old-style and - // should no longer be used. Therefore we present them only if the - // project requires compatibility with CMake 2.4. We detect this - // here by looking for the old CMAKE_BACKWARDS_COMPATIBILITY - // variable created when CMP0001 is not set to NEW. - if (this->State->GetInitializedCacheValue("CMAKE_BACKWARDS_COMPATIBILITY")) { - if (!this->State->GetInitializedCacheValue("LIBRARY_OUTPUT_PATH")) { - this->AddCacheEntry( - "LIBRARY_OUTPUT_PATH", "", - "Single output directory for building all libraries.", - cmStateEnums::PATH); - } - if (!this->State->GetInitializedCacheValue("EXECUTABLE_OUTPUT_PATH")) { - this->AddCacheEntry( - "EXECUTABLE_OUTPUT_PATH", "", - "Single output directory for building all executables.", - cmStateEnums::PATH); - } - } - const auto& mf = this->GlobalGenerator->GetMakefiles()[0]; if (mf->IsOn("CTEST_USE_LAUNCHERS") &&