2008-02-29 23:28:46 +03:00
|
|
|
#include "cmPolicies.h"
|
2016-04-29 16:40:20 +03:00
|
|
|
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmAlgorithms.h"
|
2008-02-29 23:28:46 +03:00
|
|
|
#include "cmMakefile.h"
|
2008-03-08 17:13:13 +03:00
|
|
|
#include "cmVersion.h"
|
2010-04-23 17:50:31 +04:00
|
|
|
#include "cmVersionMacros.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmake.h"
|
|
|
|
#include <assert.h>
|
2016-04-15 20:46:15 +03:00
|
|
|
#include <ctype.h>
|
2008-02-29 23:28:46 +03:00
|
|
|
#include <map>
|
|
|
|
#include <queue>
|
2016-04-29 17:53:13 +03:00
|
|
|
#include <set>
|
2008-02-29 23:28:46 +03:00
|
|
|
|
2015-05-03 11:09:29 +03:00
|
|
|
static bool stringToId(const char* input, cmPolicies::PolicyID& pid)
|
|
|
|
{
|
|
|
|
assert(input);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (strlen(input) != 7) {
|
2015-05-03 11:09:29 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!cmHasLiteralPrefix(input, "CMP")) {
|
2015-05-03 11:09:29 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (cmHasLiteralSuffix(input, "0000")) {
|
2015-05-03 11:09:29 +03:00
|
|
|
pid = cmPolicies::CMP0000;
|
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
for (int i = 3; i < 7; ++i) {
|
|
|
|
if (!isdigit(*(input + i))) {
|
2015-05-03 11:09:29 +03:00
|
|
|
return false;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-05-03 11:09:29 +03:00
|
|
|
long id;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::StringToLong(input + 3, &id)) {
|
2015-05-03 11:09:29 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (id >= cmPolicies::CMPCOUNT) {
|
2015-05-03 11:09:29 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-05-03 11:09:29 +03:00
|
|
|
pid = cmPolicies::PolicyID(id);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-05-03 11:10:20 +03:00
|
|
|
#define CM_SELECT_ID_VERSION(F, A1, A2, A3, A4, A5, A6) F(A1, A3, A4, A5)
|
2016-05-16 17:34:04 +03:00
|
|
|
#define CM_FOR_EACH_POLICY_ID_VERSION(POLICY) \
|
2015-05-03 11:10:20 +03:00
|
|
|
CM_FOR_EACH_POLICY_TABLE(POLICY, CM_SELECT_ID_VERSION)
|
|
|
|
|
2015-05-03 11:10:31 +03:00
|
|
|
#define CM_SELECT_ID_DOC(F, A1, A2, A3, A4, A5, A6) F(A1, A2)
|
2016-05-16 17:34:04 +03:00
|
|
|
#define CM_FOR_EACH_POLICY_ID_DOC(POLICY) \
|
2015-05-03 11:10:31 +03:00
|
|
|
CM_FOR_EACH_POLICY_TABLE(POLICY, CM_SELECT_ID_DOC)
|
|
|
|
|
2015-05-03 11:10:15 +03:00
|
|
|
static const char* idToString(cmPolicies::PolicyID id)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (id) {
|
|
|
|
#define POLICY_CASE(ID) \
|
|
|
|
case cmPolicies::ID: \
|
|
|
|
return #ID;
|
|
|
|
CM_FOR_EACH_POLICY_ID(POLICY_CASE)
|
2015-05-03 11:10:15 +03:00
|
|
|
#undef POLICY_CASE
|
|
|
|
case cmPolicies::CMPCOUNT:
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2015-05-03 11:10:15 +03:00
|
|
|
}
|
|
|
|
|
2015-05-03 11:10:20 +03:00
|
|
|
static const char* idToVersion(cmPolicies::PolicyID id)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (id) {
|
|
|
|
#define POLICY_CASE(ID, V_MAJOR, V_MINOR, V_PATCH) \
|
|
|
|
case cmPolicies::ID: \
|
|
|
|
return #V_MAJOR "." #V_MINOR "." #V_PATCH;
|
|
|
|
CM_FOR_EACH_POLICY_ID_VERSION(POLICY_CASE)
|
2015-05-03 11:10:20 +03:00
|
|
|
#undef POLICY_CASE
|
|
|
|
case cmPolicies::CMPCOUNT:
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2015-05-03 11:10:20 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static bool isPolicyNewerThan(cmPolicies::PolicyID id, unsigned int majorV,
|
|
|
|
unsigned int minorV, unsigned int patchV)
|
2015-05-03 11:10:27 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (id) {
|
|
|
|
#define POLICY_CASE(ID, V_MAJOR, V_MINOR, V_PATCH) \
|
|
|
|
case cmPolicies::ID: \
|
|
|
|
return ( \
|
|
|
|
majorV < V_MAJOR || (majorV == V_MAJOR && minorV + 1 < V_MINOR + 1) || \
|
|
|
|
(majorV == V_MAJOR && minorV == V_MINOR && patchV + 1 < V_PATCH + 1));
|
|
|
|
CM_FOR_EACH_POLICY_ID_VERSION(POLICY_CASE)
|
2015-05-03 11:10:27 +03:00
|
|
|
#undef POLICY_CASE
|
|
|
|
case cmPolicies::CMPCOUNT:
|
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-05-03 11:10:27 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-05-03 11:10:31 +03:00
|
|
|
const char* idToShortDescription(cmPolicies::PolicyID id)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
switch (id) {
|
|
|
|
#define POLICY_CASE(ID, SHORT_DESCRIPTION) \
|
|
|
|
case cmPolicies::ID: \
|
|
|
|
return SHORT_DESCRIPTION;
|
|
|
|
CM_FOR_EACH_POLICY_ID_DOC(POLICY_CASE)
|
2015-05-03 11:10:31 +03:00
|
|
|
#undef POLICY_CASE
|
|
|
|
case cmPolicies::CMPCOUNT:
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2015-05-03 11:10:31 +03:00
|
|
|
}
|
|
|
|
|
2015-05-03 11:10:35 +03:00
|
|
|
static void DiagnoseAncientPolicies(
|
2016-05-16 17:34:04 +03:00
|
|
|
std::vector<cmPolicies::PolicyID> const& ancient, unsigned int majorVer,
|
|
|
|
unsigned int minorVer, unsigned int patchVer, cmMakefile* mf)
|
2015-05-03 11:10:35 +03:00
|
|
|
{
|
|
|
|
std::ostringstream e;
|
|
|
|
e << "The project requests behavior compatible with CMake version \""
|
|
|
|
<< majorVer << "." << minorVer << "." << patchVer
|
|
|
|
<< "\", which requires the OLD behavior for some policies:\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmPolicies::PolicyID>::const_iterator i = ancient.begin();
|
|
|
|
i != ancient.end(); ++i) {
|
2015-05-03 11:10:35 +03:00
|
|
|
e << " " << idToString(*i) << ": " << idToShortDescription(*i) << "\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-05-03 11:10:35 +03:00
|
|
|
e << "However, this version of CMake no longer supports the OLD "
|
|
|
|
<< "behavior for these policies. "
|
|
|
|
<< "Please either update your CMakeLists.txt files to conform to "
|
|
|
|
<< "the new behavior or use an older version of CMake that still "
|
|
|
|
<< "supports the old behavior.";
|
|
|
|
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
|
|
|
|
}
|
|
|
|
|
2015-05-03 11:09:10 +03:00
|
|
|
static bool GetPolicyDefault(cmMakefile* mf, std::string const& policy,
|
|
|
|
cmPolicies::PolicyStatus* defaultSetting)
|
|
|
|
{
|
|
|
|
std::string defaultVar = "CMAKE_POLICY_DEFAULT_" + policy;
|
|
|
|
std::string defaultValue = mf->GetSafeDefinition(defaultVar);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (defaultValue == "NEW") {
|
2015-05-03 11:09:10 +03:00
|
|
|
*defaultSetting = cmPolicies::NEW;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (defaultValue == "OLD") {
|
2015-05-03 11:09:10 +03:00
|
|
|
*defaultSetting = cmPolicies::OLD;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (defaultValue == "") {
|
2015-05-03 11:09:10 +03:00
|
|
|
*defaultSetting = cmPolicies::WARN;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-05-03 11:09:10 +03:00
|
|
|
std::ostringstream e;
|
|
|
|
e << defaultVar << " has value \"" << defaultValue
|
|
|
|
<< "\" but must be \"OLD\", \"NEW\", or \"\" (empty).";
|
|
|
|
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
|
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-05-03 11:09:10 +03:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf, const char* version)
|
2008-02-29 23:28:46 +03:00
|
|
|
{
|
|
|
|
std::string ver = "2.4.0";
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (version && strlen(version) > 0) {
|
2008-02-29 23:28:46 +03:00
|
|
|
ver = version;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-02-29 23:28:46 +03:00
|
|
|
|
|
|
|
unsigned int majorVer = 2;
|
|
|
|
unsigned int minorVer = 0;
|
|
|
|
unsigned int patchVer = 0;
|
2010-04-23 17:50:31 +04:00
|
|
|
unsigned int tweakVer = 0;
|
2008-03-06 01:26:32 +03:00
|
|
|
|
2008-02-29 23:28:46 +03:00
|
|
|
// parse the string
|
2016-05-16 17:34:04 +03:00
|
|
|
if (sscanf(ver.c_str(), "%u.%u.%u.%u", &majorVer, &minorVer, &patchVer,
|
|
|
|
&tweakVer) < 2) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2008-03-24 17:56:26 +03:00
|
|
|
e << "Invalid policy version value \"" << ver << "\". "
|
2010-04-23 17:50:31 +04:00
|
|
|
<< "A numeric major.minor[.patch[.tweak]] must be given.";
|
2008-03-24 17:56:26 +03:00
|
|
|
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
|
2008-03-06 02:20:20 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-08-28 18:01:49 +04:00
|
|
|
|
2008-03-07 19:43:47 +03:00
|
|
|
// it is an error if the policy version is less than 2.4
|
2016-05-16 17:34:04 +03:00
|
|
|
if (majorVer < 2 || (majorVer == 2 && minorVer < 4)) {
|
|
|
|
mf->IssueMessage(
|
|
|
|
cmake::FATAL_ERROR,
|
2013-10-18 19:25:49 +04:00
|
|
|
"Compatibility with CMake < 2.4 is not supported by CMake >= 3.0. "
|
|
|
|
"For compatibility with older versions please use any CMake 2.8.x "
|
|
|
|
"release or lower.");
|
2008-03-24 17:56:26 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-03-24 17:56:26 +03:00
|
|
|
|
|
|
|
// It is an error if the policy version is greater than the running
|
|
|
|
// CMake.
|
|
|
|
if (majorVer > cmVersion::GetMajorVersion() ||
|
|
|
|
(majorVer == cmVersion::GetMajorVersion() &&
|
|
|
|
minorVer > cmVersion::GetMinorVersion()) ||
|
|
|
|
(majorVer == cmVersion::GetMajorVersion() &&
|
|
|
|
minorVer == cmVersion::GetMinorVersion() &&
|
2010-04-23 17:50:31 +04:00
|
|
|
patchVer > cmVersion::GetPatchVersion()) ||
|
|
|
|
(majorVer == cmVersion::GetMajorVersion() &&
|
|
|
|
minorVer == cmVersion::GetMinorVersion() &&
|
|
|
|
patchVer == cmVersion::GetPatchVersion() &&
|
2016-05-16 17:34:04 +03:00
|
|
|
tweakVer > cmVersion::GetTweakVersion())) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2008-03-24 17:56:26 +03:00
|
|
|
e << "An attempt was made to set the policy version of CMake to \""
|
|
|
|
<< version << "\" which is greater than this version of CMake. "
|
|
|
|
<< "This is not allowed because the greater version may have new "
|
|
|
|
<< "policies not known to this CMake. "
|
|
|
|
<< "You may need a newer CMake version to build this project.";
|
|
|
|
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
|
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-03-07 23:30:35 +03:00
|
|
|
|
2008-02-29 23:28:46 +03:00
|
|
|
// now loop over all the policies and set them as appropriate
|
2008-08-19 00:29:00 +04:00
|
|
|
std::vector<cmPolicies::PolicyID> ancientPolicies;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (PolicyID pid = cmPolicies::CMP0000; pid != cmPolicies::CMPCOUNT;
|
|
|
|
pid = PolicyID(pid + 1)) {
|
|
|
|
if (isPolicyNewerThan(pid, majorVer, minorVer, patchVer)) {
|
|
|
|
if (cmPolicies::GetPolicyStatus(pid) == cmPolicies::REQUIRED_ALWAYS) {
|
2015-05-03 11:10:42 +03:00
|
|
|
ancientPolicies.push_back(pid);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2011-01-04 02:04:58 +03:00
|
|
|
cmPolicies::PolicyStatus status = cmPolicies::WARN;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!GetPolicyDefault(mf, idToString(pid), &status) ||
|
|
|
|
!mf->SetPolicy(pid, status)) {
|
2011-01-04 02:04:58 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (pid == cmPolicies::CMP0001 &&
|
|
|
|
(status == cmPolicies::WARN || status == cmPolicies::OLD)) {
|
|
|
|
if (!(mf->GetState()->GetInitializedCacheValue(
|
|
|
|
"CMAKE_BACKWARDS_COMPATIBILITY"))) {
|
2015-07-06 03:10:25 +03:00
|
|
|
// Set it to 2.4 because that is the last version where the
|
|
|
|
// variable had meaning.
|
2016-05-16 17:34:04 +03:00
|
|
|
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.",
|
|
|
|
cmState::STRING);
|
2015-07-06 03:10:25 +03:00
|
|
|
}
|
2010-11-23 23:53:35 +03:00
|
|
|
}
|
2008-02-29 23:28:46 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
|
|
|
if (!mf->SetPolicy(pid, cmPolicies::NEW)) {
|
2008-02-29 23:28:46 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-02-29 23:28:46 +03:00
|
|
|
|
2008-08-19 00:29:00 +04:00
|
|
|
// Make sure the project does not use any ancient policies.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!ancientPolicies.empty()) {
|
|
|
|
DiagnoseAncientPolicies(ancientPolicies, majorVer, minorVer, patchVer, mf);
|
2008-08-19 00:29:00 +04:00
|
|
|
cmSystemTools::SetFatalErrorOccured();
|
2008-02-29 23:28:46 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-02-29 23:28:46 +03:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmPolicies::GetPolicyID(const char* id, cmPolicies::PolicyID& pid)
|
2008-02-29 23:28:46 +03:00
|
|
|
{
|
2015-05-03 11:09:29 +03:00
|
|
|
return stringToId(id, pid);
|
2008-02-29 23:28:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
///! return a warning string for a given policy
|
|
|
|
std::string cmPolicies::GetPolicyWarning(cmPolicies::PolicyID id)
|
|
|
|
{
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream msg;
|
2016-05-16 17:34:04 +03:00
|
|
|
msg << "Policy " << idToString(id) << " is not set: "
|
|
|
|
""
|
|
|
|
<< idToShortDescription(id) << " "
|
|
|
|
"Run \"cmake --help-policy "
|
|
|
|
<< idToString(id) << "\" for "
|
|
|
|
"policy details. "
|
|
|
|
"Use the cmake_policy command to set the policy "
|
|
|
|
"and suppress this warning.";
|
2008-03-06 02:42:46 +03:00
|
|
|
return msg.str();
|
2008-02-29 23:28:46 +03:00
|
|
|
}
|
2010-08-28 18:01:49 +04:00
|
|
|
|
2008-02-29 23:28:46 +03:00
|
|
|
///! return an error string for when a required policy is unspecified
|
|
|
|
std::string cmPolicies::GetRequiredPolicyError(cmPolicies::PolicyID id)
|
|
|
|
{
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream error;
|
2016-05-16 17:34:04 +03:00
|
|
|
error << "Policy " << idToString(id) << " is not set to NEW: "
|
|
|
|
""
|
|
|
|
<< idToShortDescription(id) << " "
|
|
|
|
"Run \"cmake --help-policy "
|
|
|
|
<< idToString(id)
|
|
|
|
<< "\" for "
|
|
|
|
"policy details. "
|
|
|
|
"CMake now requires this policy to be set to NEW by the project. "
|
|
|
|
"The policy may be set explicitly using the code\n"
|
|
|
|
" cmake_policy(SET "
|
|
|
|
<< idToString(id) << " NEW)\n"
|
|
|
|
"or by upgrading all policies with the code\n"
|
|
|
|
" cmake_policy(VERSION "
|
|
|
|
<< idToVersion(id)
|
|
|
|
<< ") # or later\n"
|
|
|
|
"Run \"cmake --help-command cmake_policy\" for more information.";
|
2008-02-29 23:28:46 +03:00
|
|
|
return error.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
///! Get the default status for a policy
|
2016-08-17 02:49:57 +03:00
|
|
|
cmPolicies::PolicyStatus cmPolicies::GetPolicyStatus(
|
|
|
|
cmPolicies::PolicyID /*unused*/)
|
2008-02-29 23:28:46 +03:00
|
|
|
{
|
2015-05-03 11:10:38 +03:00
|
|
|
return cmPolicies::WARN;
|
2008-02-29 23:28:46 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string cmPolicies::GetRequiredAlwaysPolicyError(cmPolicies::PolicyID id)
|
2008-08-19 00:29:00 +04:00
|
|
|
{
|
2015-05-03 11:10:15 +03:00
|
|
|
std::string pid = idToString(id);
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2008-08-19 00:29:00 +04:00
|
|
|
e << "Policy " << pid << " may not be set to OLD behavior because this "
|
|
|
|
<< "version of CMake no longer supports it. "
|
|
|
|
<< "The policy was introduced in "
|
2015-05-03 11:10:20 +03:00
|
|
|
<< "CMake version " << idToVersion(id)
|
2008-08-19 00:29:00 +04:00
|
|
|
<< ", and use of NEW behavior is now required."
|
|
|
|
<< "\n"
|
|
|
|
<< "Please either update your CMakeLists.txt files to conform to "
|
|
|
|
<< "the new behavior or use an older version of CMake that still "
|
|
|
|
<< "supports the old behavior. "
|
|
|
|
<< "Run cmake --help-policy " << pid << " for more information.";
|
|
|
|
return e.str();
|
|
|
|
}
|
2015-05-03 11:12:28 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmPolicies::PolicyStatus cmPolicies::PolicyMap::Get(
|
|
|
|
cmPolicies::PolicyID id) const
|
2015-05-03 11:12:28 +03:00
|
|
|
{
|
2015-05-03 11:12:34 +03:00
|
|
|
PolicyStatus status = cmPolicies::WARN;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Status[(POLICY_STATUS_COUNT * id) + OLD]) {
|
2015-05-03 11:12:34 +03:00
|
|
|
status = cmPolicies::OLD;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (this->Status[(POLICY_STATUS_COUNT * id) + NEW]) {
|
2015-05-03 11:12:34 +03:00
|
|
|
status = cmPolicies::NEW;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-05-03 11:12:34 +03:00
|
|
|
return status;
|
2015-05-03 11:12:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmPolicies::PolicyMap::Set(cmPolicies::PolicyID id,
|
|
|
|
cmPolicies::PolicyStatus status)
|
|
|
|
{
|
2015-06-06 10:41:05 +03:00
|
|
|
this->Status[(POLICY_STATUS_COUNT * id) + OLD] = (status == OLD);
|
|
|
|
this->Status[(POLICY_STATUS_COUNT * id) + WARN] = (status == WARN);
|
|
|
|
this->Status[(POLICY_STATUS_COUNT * id) + NEW] = (status == NEW);
|
2015-05-03 11:12:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool cmPolicies::PolicyMap::IsDefined(cmPolicies::PolicyID id) const
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
return this->Status[(POLICY_STATUS_COUNT * id) + OLD] ||
|
|
|
|
this->Status[(POLICY_STATUS_COUNT * id) + WARN] ||
|
|
|
|
this->Status[(POLICY_STATUS_COUNT * id) + NEW];
|
2015-05-03 11:12:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool cmPolicies::PolicyMap::IsEmpty() const
|
|
|
|
{
|
2015-06-06 10:41:05 +03:00
|
|
|
return this->Status.none();
|
2015-05-03 11:12:28 +03:00
|
|
|
}
|