mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-20 04:24:36 +08:00
Deprecate compatibility with CMake versions older than 2.8.12
Issue a deprecation warning on calls to `cmake_minimum_required` or
`cmake_policy` that set policies based on versions older than 2.8.12.
Note that the effective policy version includes `...<max>` treatment.
This is important in combination with commit ca24b70d31
(Export: Specify
a policy range in exported files, 2020-05-16, v3.18.0-rc1~133^2).
This commit is contained in:
@@ -6,3 +6,8 @@ deprecate-policy-old
|
||||
The :manual:`cmake-policies(7)` manual explains that the OLD behaviors
|
||||
of all policies are deprecated and that projects should port to the
|
||||
NEW behaviors.
|
||||
|
||||
* Compatibility with versions of CMake older than 2.8.12 is now deprecated
|
||||
and will be removed from a future version. Calls to
|
||||
:command:`cmake_minimum_required` or :command:`cmake_policy` that set
|
||||
the policy version to an older value now issue a deprecation diagnostic.
|
||||
|
@@ -1659,7 +1659,8 @@ void cmMakefile::Configure()
|
||||
this->SetCheckCMP0000(true);
|
||||
|
||||
// Implicitly set the version for the user.
|
||||
this->SetPolicyVersion("2.4", std::string());
|
||||
cmPolicies::ApplyPolicyVersion(this, 2, 4, 0,
|
||||
cmPolicies::WarnCompat::Off);
|
||||
}
|
||||
}
|
||||
bool hasProject = false;
|
||||
@@ -4621,7 +4622,8 @@ void cmMakefile::PopSnapshot(bool reportError)
|
||||
bool cmMakefile::SetPolicyVersion(std::string const& version_min,
|
||||
std::string const& version_max)
|
||||
{
|
||||
return cmPolicies::ApplyPolicyVersion(this, version_min, version_max);
|
||||
return cmPolicies::ApplyPolicyVersion(this, version_min, version_max,
|
||||
cmPolicies::WarnCompat::On);
|
||||
}
|
||||
|
||||
bool cmMakefile::HasCMP0054AlreadyBeenReported(
|
||||
|
@@ -7,9 +7,11 @@
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
#include "cmListFileCache.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmMessageType.h"
|
||||
#include "cmState.h"
|
||||
#include "cmStateSnapshot.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
@@ -157,7 +159,8 @@ static bool GetPolicyDefault(cmMakefile* mf, std::string const& policy,
|
||||
|
||||
bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf,
|
||||
std::string const& version_min,
|
||||
std::string const& version_max)
|
||||
std::string const& version_max,
|
||||
WarnCompat warnCompat)
|
||||
{
|
||||
// Parse components of the minimum version.
|
||||
unsigned int minMajor = 2;
|
||||
@@ -244,13 +247,34 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf,
|
||||
polPatch = maxPatch;
|
||||
}
|
||||
|
||||
return cmPolicies::ApplyPolicyVersion(mf, polMajor, polMinor, polPatch);
|
||||
return cmPolicies::ApplyPolicyVersion(mf, polMajor, polMinor, polPatch,
|
||||
warnCompat);
|
||||
}
|
||||
|
||||
bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf, unsigned int majorVer,
|
||||
unsigned int minorVer,
|
||||
unsigned int patchVer)
|
||||
unsigned int patchVer,
|
||||
WarnCompat warnCompat)
|
||||
{
|
||||
// Warn about policy versions for which support will be removed.
|
||||
if (warnCompat == WarnCompat::On &&
|
||||
(majorVer < 2 || (majorVer == 2 && minorVer < 8) ||
|
||||
(majorVer == 2 && minorVer == 8 && patchVer < 12)) &&
|
||||
// Avoid warning on calls generated by install(EXPORT)
|
||||
// in CMake versions prior to 3.18.
|
||||
!(majorVer == 2 && minorVer == 6 && patchVer == 0 &&
|
||||
mf->GetStateSnapshot().CanPopPolicyScope() &&
|
||||
cmSystemTools::Strucmp(mf->GetBacktrace().Top().Name.c_str(),
|
||||
"cmake_policy") == 0)) {
|
||||
mf->IssueMessage(
|
||||
MessageType::DEPRECATION_WARNING,
|
||||
"Compatibility with CMake < 2.8.12 will be removed from "
|
||||
"a future version of CMake.\n"
|
||||
"Update the VERSION argument <min> value or use a ...<max> suffix "
|
||||
"to tell CMake that the project does not need compatibility with "
|
||||
"older versions.");
|
||||
}
|
||||
|
||||
// now loop over all the policies and set them as appropriate
|
||||
std::vector<cmPolicies::PolicyID> ancientPolicies;
|
||||
for (PolicyID pid = cmPolicies::CMP0000; pid != cmPolicies::CMPCOUNT;
|
||||
|
@@ -399,12 +399,20 @@ public:
|
||||
//! Get the default status for a policy
|
||||
static cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id);
|
||||
|
||||
enum class WarnCompat
|
||||
{
|
||||
Off,
|
||||
On
|
||||
};
|
||||
|
||||
//! Set a policy level for this listfile
|
||||
static bool ApplyPolicyVersion(cmMakefile* mf,
|
||||
std::string const& version_min,
|
||||
std::string const& version_max);
|
||||
std::string const& version_max,
|
||||
WarnCompat warnCompat);
|
||||
static bool ApplyPolicyVersion(cmMakefile* mf, unsigned int majorVer,
|
||||
unsigned int minorVer, unsigned int patchVer);
|
||||
unsigned int minorVer, unsigned int patchVer,
|
||||
WarnCompat warnCompat);
|
||||
|
||||
//! return a warning string for a given policy
|
||||
static std::string GetPolicyWarning(cmPolicies::PolicyID id);
|
||||
|
6
Tests/RunCMake/CMP0019/CMP0019-NEW-stderr.txt
Normal file
6
Tests/RunCMake/CMP0019/CMP0019-NEW-stderr.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
^CMake Deprecation Warning at CMakeLists.txt:1 \(cmake_minimum_required\):
|
||||
Compatibility with CMake < 2.8.12 will be removed from a future version of
|
||||
CMake.
|
||||
|
||||
Update the VERSION argument <min> value or use a ...<max> suffix to tell
|
||||
CMake that the project does not need compatibility with older versions.$
|
@@ -1,4 +1,11 @@
|
||||
^CMake Deprecation Warning at CMP0019-OLD.cmake:[0-9]+ \(cmake_policy\):
|
||||
^CMake Deprecation Warning at CMakeLists.txt:1 \(cmake_minimum_required\):
|
||||
Compatibility with CMake < 2.8.12 will be removed from a future version of
|
||||
CMake.
|
||||
|
||||
Update the VERSION argument <min> value or use a ...<max> suffix to tell
|
||||
CMake that the project does not need compatibility with older versions.
|
||||
+
|
||||
CMake Deprecation Warning at CMP0019-OLD.cmake:[0-9]+ \(cmake_policy\):
|
||||
The OLD behavior for policy CMP0019 will be removed from a future version
|
||||
of CMake.
|
||||
|
||||
|
@@ -1,3 +1,10 @@
|
||||
^CMake Deprecation Warning at CMakeLists.txt:1 \(cmake_minimum_required\):
|
||||
Compatibility with CMake < 2.8.12 will be removed from a future version of
|
||||
CMake.
|
||||
|
||||
Update the VERSION argument <min> value or use a ...<max> suffix to tell
|
||||
CMake that the project does not need compatibility with older versions.
|
||||
+
|
||||
CMake Warning \(dev\) in CMakeLists.txt:
|
||||
Policy CMP0019 is not set: Do not re-expand variables in include and link
|
||||
information. Run "cmake --help-policy CMP0019" for policy details. Use
|
||||
|
6
Tests/RunCMake/CMP0022/CMP0022-NOWARN-exe-stderr.txt
Normal file
6
Tests/RunCMake/CMP0022/CMP0022-NOWARN-exe-stderr.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
^CMake Deprecation Warning at CMakeLists.txt:1 \(cmake_minimum_required\):
|
||||
Compatibility with CMake < 2.8.12 will be removed from a future version of
|
||||
CMake.
|
||||
|
||||
Update the VERSION argument <min> value or use a ...<max> suffix to tell
|
||||
CMake that the project does not need compatibility with older versions.$
|
6
Tests/RunCMake/CMP0022/CMP0022-NOWARN-shared-stderr.txt
Normal file
6
Tests/RunCMake/CMP0022/CMP0022-NOWARN-shared-stderr.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
^CMake Deprecation Warning at CMakeLists.txt:1 \(cmake_minimum_required\):
|
||||
Compatibility with CMake < 2.8.12 will be removed from a future version of
|
||||
CMake.
|
||||
|
||||
Update the VERSION argument <min> value or use a ...<max> suffix to tell
|
||||
CMake that the project does not need compatibility with older versions.$
|
@@ -0,0 +1,6 @@
|
||||
^CMake Deprecation Warning at CMakeLists.txt:1 \(cmake_minimum_required\):
|
||||
Compatibility with CMake < 2.8.12 will be removed from a future version of
|
||||
CMake.
|
||||
|
||||
Update the VERSION argument <min> value or use a ...<max> suffix to tell
|
||||
CMake that the project does not need compatibility with older versions.$
|
@@ -0,0 +1,6 @@
|
||||
^CMake Deprecation Warning at CMakeLists.txt:1 \(cmake_minimum_required\):
|
||||
Compatibility with CMake < 2.8.12 will be removed from a future version of
|
||||
CMake.
|
||||
|
||||
Update the VERSION argument <min> value or use a ...<max> suffix to tell
|
||||
CMake that the project does not need compatibility with older versions.$
|
6
Tests/RunCMake/CMP0022/CMP0022-NOWARN-static-stderr.txt
Normal file
6
Tests/RunCMake/CMP0022/CMP0022-NOWARN-static-stderr.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
^CMake Deprecation Warning at CMakeLists.txt:1 \(cmake_minimum_required\):
|
||||
Compatibility with CMake < 2.8.12 will be removed from a future version of
|
||||
CMake.
|
||||
|
||||
Update the VERSION argument <min> value or use a ...<max> suffix to tell
|
||||
CMake that the project does not need compatibility with older versions.$
|
@@ -1,3 +1,10 @@
|
||||
^CMake Deprecation Warning at CMakeLists.txt:1 \(cmake_minimum_required\):
|
||||
Compatibility with CMake < 2.8.12 will be removed from a future version of
|
||||
CMake.
|
||||
|
||||
Update the VERSION argument <min> value or use a ...<max> suffix to tell
|
||||
CMake that the project does not need compatibility with older versions.
|
||||
+
|
||||
CMake Warning \(dev\) in CMakeLists.txt:
|
||||
Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link
|
||||
interface. Run "cmake --help-policy CMP0022" for policy details. Use the
|
||||
|
@@ -1,4 +1,11 @@
|
||||
^CMake Warning \(dev\) in CMakeLists.txt:
|
||||
^CMake Deprecation Warning at CMakeLists.txt:1 \(cmake_minimum_required\):
|
||||
Compatibility with CMake < 2.8.12 will be removed from a future version of
|
||||
CMake.
|
||||
|
||||
Update the VERSION argument <min> value or use a ...<max> suffix to tell
|
||||
CMake that the project does not need compatibility with older versions.
|
||||
+
|
||||
CMake Warning \(dev\) in CMakeLists.txt:
|
||||
Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link
|
||||
interface. Run "cmake --help-policy CMP0022" for policy details. Use the
|
||||
cmake_policy command to set the policy and suppress this warning.
|
||||
|
6
Tests/RunCMake/CMP0022/CMP0022-export-exe-stderr.txt
Normal file
6
Tests/RunCMake/CMP0022/CMP0022-export-exe-stderr.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
^CMake Deprecation Warning at CMakeLists.txt:1 \(cmake_minimum_required\):
|
||||
Compatibility with CMake < 2.8.12 will be removed from a future version of
|
||||
CMake.
|
||||
|
||||
Update the VERSION argument <min> value or use a ...<max> suffix to tell
|
||||
CMake that the project does not need compatibility with older versions.$
|
26
Tests/RunCMake/cmake_minimum_required/Before2812-stderr.txt
Normal file
26
Tests/RunCMake/cmake_minimum_required/Before2812-stderr.txt
Normal file
@@ -0,0 +1,26 @@
|
||||
^CMake Deprecation Warning at Before2812.cmake:1 \(cmake_minimum_required\):
|
||||
Compatibility with CMake < 2.8.12 will be removed from a future version of
|
||||
CMake.
|
||||
|
||||
Update the VERSION argument <min> value or use a ...<max> suffix to tell
|
||||
CMake that the project does not need compatibility with older versions.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
+
|
||||
CMake Deprecation Warning at Before2812.cmake:2 \(cmake_policy\):
|
||||
Compatibility with CMake < 2.8.12 will be removed from a future version of
|
||||
CMake.
|
||||
|
||||
Update the VERSION argument <min> value or use a ...<max> suffix to tell
|
||||
CMake that the project does not need compatibility with older versions.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
+
|
||||
CMake Deprecation Warning at Before2812.cmake:6 \(cmake_policy\):
|
||||
Compatibility with CMake < 2.8.12 will be removed from a future version of
|
||||
CMake.
|
||||
|
||||
Update the VERSION argument <min> value or use a ...<max> suffix to tell
|
||||
CMake that the project does not need compatibility with older versions.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)$
|
6
Tests/RunCMake/cmake_minimum_required/Before2812.cmake
Normal file
6
Tests/RunCMake/cmake_minimum_required/Before2812.cmake
Normal file
@@ -0,0 +1,6 @@
|
||||
cmake_minimum_required(VERSION 2.8.11)
|
||||
cmake_policy(VERSION 2.6)
|
||||
cmake_policy(PUSH)
|
||||
cmake_policy(VERSION 2.6) # simulate pre-3.18 install(EXPORT)-generated call
|
||||
cmake_policy(POP)
|
||||
cmake_policy(VERSION 2.8.11)
|
@@ -1,3 +1,3 @@
|
||||
cmake_minimum_required(VERSION 2.8.12)
|
||||
project(${RunCMake_TEST} NONE)
|
||||
include(${RunCMake_TEST}.cmake)
|
||||
include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE)
|
||||
|
@@ -1,3 +1,12 @@
|
||||
^CMake Deprecation Warning at CompatBefore24.cmake:1 \(cmake_minimum_required\):
|
||||
Compatibility with CMake < 2.8.12 will be removed from a future version of
|
||||
CMake.
|
||||
|
||||
Update the VERSION argument <min> value or use a ...<max> suffix to tell
|
||||
CMake that the project does not need compatibility with older versions.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
+
|
||||
CMake Error in CMakeLists.txt:
|
||||
You have set CMAKE_BACKWARDS_COMPATIBILITY to a CMake version less than
|
||||
2.4. This version of CMake only supports backwards compatibility with
|
||||
|
@@ -4,6 +4,7 @@ run_cmake(Before24)
|
||||
run_cmake(CompatBefore24)
|
||||
run_cmake(Future)
|
||||
run_cmake(PolicyBefore24)
|
||||
run_cmake(Before2812)
|
||||
run_cmake(Range)
|
||||
run_cmake(RangeBad)
|
||||
run_cmake(Unknown)
|
||||
|
@@ -1,4 +1,13 @@
|
||||
^CMake Warning \(dev\) at GET-CMP0007-WARN.cmake:4 \(list\):
|
||||
^CMake Deprecation Warning at GET-CMP0007-WARN.cmake:1 \(cmake_policy\):
|
||||
Compatibility with CMake < 2.8.12 will be removed from a future version of
|
||||
CMake.
|
||||
|
||||
Update the VERSION argument <min> value or use a ...<max> suffix to tell
|
||||
CMake that the project does not need compatibility with older versions.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
+
|
||||
CMake Warning \(dev\) at GET-CMP0007-WARN.cmake:4 \(list\):
|
||||
Policy CMP0007 is not set: list command no longer ignores empty elements.
|
||||
Run "cmake --help-policy CMP0007" for policy details. Use the cmake_policy
|
||||
command to set the policy and suppress this warning. List has value =
|
||||
|
Reference in New Issue
Block a user