summaryrefslogtreecommitdiff
path: root/Source/cmPolicies.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-06-12 08:41:32 -0400
committerBrad King <brad.king@kitware.com>2020-06-18 09:52:05 -0400
commit5845c218d771b517aa4294f0a90267e6f3f64891 (patch)
tree496f8fae5d48677d97df29b082771aa31fe76218 /Source/cmPolicies.cxx
parent7b07ccdd2b8d621211ee1642e8b62b005b0cd60f (diff)
downloadcmake-5845c218d771b517aa4294f0a90267e6f3f64891.tar.gz
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).
Diffstat (limited to 'Source/cmPolicies.cxx')
-rw-r--r--Source/cmPolicies.cxx30
1 files changed, 27 insertions, 3 deletions
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index dea3f8a356..01e8c047a0 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -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;