|
|
@@ -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;
|