mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-07 22:30:13 -06:00
CMP0001: Remove support for OLD behavior
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CMAKE_BACKWARDS_COMPATIBILITY
|
||||
-----------------------------
|
||||
|
||||
Deprecated. See CMake Policy :policy:`CMP0001` documentation.
|
||||
Removed. See policy :policy:`CMP0001`.
|
||||
|
||||
@@ -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<std::string> const& args,
|
||||
@@ -88,20 +85,6 @@ bool HandleSetMode(std::vector<std::string> 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
#include <cm/optional>
|
||||
|
||||
#include <cm3p/kwiml/int.h>
|
||||
|
||||
#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
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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( \
|
||||
|
||||
@@ -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") &&
|
||||
|
||||
Reference in New Issue
Block a user