"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Source/cmPolicies.cxx" between
cmake-3.13.4.tar.gz and cmake-3.14.0-rc1.tar.gz

About: CMake is a cross-platform build system designed to build, test and package software. Release candidate.

cmPolicies.cxx  (cmake-3.13.4):cmPolicies.cxx  (cmake-3.14.0-rc1)
#include "cmPolicies.h" #include "cmPolicies.h"
#include "cmAlgorithms.h" #include "cmAlgorithms.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmState.h" #include "cmState.h"
#include "cmStateTypes.h" #include "cmStateTypes.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmVersion.h" #include "cmVersion.h"
#include "cmake.h"
#include <assert.h> #include <assert.h>
#include <ctype.h> #include <ctype.h>
#include <sstream> #include <sstream>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <vector> #include <vector>
static bool stringToId(const char* input, cmPolicies::PolicyID& pid) static bool stringToId(const char* input, cmPolicies::PolicyID& pid)
{ {
skipping to change at line 131 skipping to change at line 131
<< majorVer << "." << minorVer << "." << patchVer << majorVer << "." << minorVer << "." << patchVer
<< "\", which requires the OLD behavior for some policies:\n"; << "\", which requires the OLD behavior for some policies:\n";
for (cmPolicies::PolicyID i : ancient) { for (cmPolicies::PolicyID i : ancient) {
e << " " << idToString(i) << ": " << idToShortDescription(i) << "\n"; e << " " << idToString(i) << ": " << idToShortDescription(i) << "\n";
} }
e << "However, this version of CMake no longer supports the OLD " e << "However, this version of CMake no longer supports the OLD "
<< "behavior for these policies. " << "behavior for these policies. "
<< "Please either update your CMakeLists.txt files to conform to " << "Please either update your CMakeLists.txt files to conform to "
<< "the new behavior or use an older version of CMake that still " << "the new behavior or use an older version of CMake that still "
<< "supports the old behavior."; << "supports the old behavior.";
mf->IssueMessage(cmake::FATAL_ERROR, e.str()); mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
} }
static bool GetPolicyDefault(cmMakefile* mf, std::string const& policy, static bool GetPolicyDefault(cmMakefile* mf, std::string const& policy,
cmPolicies::PolicyStatus* defaultSetting) cmPolicies::PolicyStatus* defaultSetting)
{ {
std::string defaultVar = "CMAKE_POLICY_DEFAULT_" + policy; std::string defaultVar = "CMAKE_POLICY_DEFAULT_" + policy;
std::string const& defaultValue = mf->GetSafeDefinition(defaultVar); std::string const& defaultValue = mf->GetSafeDefinition(defaultVar);
if (defaultValue == "NEW") { if (defaultValue == "NEW") {
*defaultSetting = cmPolicies::NEW; *defaultSetting = cmPolicies::NEW;
} else if (defaultValue == "OLD") { } else if (defaultValue == "OLD") {
*defaultSetting = cmPolicies::OLD; *defaultSetting = cmPolicies::OLD;
} else if (defaultValue.empty()) { } else if (defaultValue.empty()) {
*defaultSetting = cmPolicies::WARN; *defaultSetting = cmPolicies::WARN;
} else { } else {
std::ostringstream e; std::ostringstream e;
e << defaultVar << " has value \"" << defaultValue e << defaultVar << " has value \"" << defaultValue
<< "\" but must be \"OLD\", \"NEW\", or \"\" (empty)."; << "\" but must be \"OLD\", \"NEW\", or \"\" (empty).";
mf->IssueMessage(cmake::FATAL_ERROR, e.str()); mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
return false; return false;
} }
return true; return true;
} }
bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf, bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf,
std::string const& version_min, std::string const& version_min,
std::string const& version_max) std::string const& version_max)
{ {
// Parse components of the minimum version. // Parse components of the minimum version.
unsigned int minMajor = 2; unsigned int minMajor = 2;
unsigned int minMinor = 0; unsigned int minMinor = 0;
unsigned int minPatch = 0; unsigned int minPatch = 0;
unsigned int minTweak = 0; unsigned int minTweak = 0;
if (sscanf(version_min.c_str(), "%u.%u.%u.%u", &minMajor, &minMinor, if (sscanf(version_min.c_str(), "%u.%u.%u.%u", &minMajor, &minMinor,
&minPatch, &minTweak) < 2) { &minPatch, &minTweak) < 2) {
std::ostringstream e; std::ostringstream e;
e << "Invalid policy version value \"" << version_min << "\". " e << "Invalid policy version value \"" << version_min << "\". "
<< "A numeric major.minor[.patch[.tweak]] must be given."; << "A numeric major.minor[.patch[.tweak]] must be given.";
mf->IssueMessage(cmake::FATAL_ERROR, e.str()); mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
return false; return false;
} }
// it is an error if the policy version is less than 2.4 // it is an error if the policy version is less than 2.4
if (minMajor < 2 || (minMajor == 2 && minMinor < 4)) { if (minMajor < 2 || (minMajor == 2 && minMinor < 4)) {
mf->IssueMessage( mf->IssueMessage(
cmake::FATAL_ERROR, MessageType::FATAL_ERROR,
"Compatibility with CMake < 2.4 is not supported by CMake >= 3.0. " "Compatibility with CMake < 2.4 is not supported by CMake >= 3.0. "
"For compatibility with older versions please use any CMake 2.8.x " "For compatibility with older versions please use any CMake 2.8.x "
"release or lower."); "release or lower.");
return false; return false;
} }
// It is an error if the policy version is greater than the running // It is an error if the policy version is greater than the running
// CMake. // CMake.
if (minMajor > cmVersion::GetMajorVersion() || if (minMajor > cmVersion::GetMajorVersion() ||
(minMajor == cmVersion::GetMajorVersion() && (minMajor == cmVersion::GetMajorVersion() &&
skipping to change at line 202 skipping to change at line 202
(minMajor == cmVersion::GetMajorVersion() && (minMajor == cmVersion::GetMajorVersion() &&
minMinor == cmVersion::GetMinorVersion() && minMinor == cmVersion::GetMinorVersion() &&
minPatch == cmVersion::GetPatchVersion() && minPatch == cmVersion::GetPatchVersion() &&
minTweak > cmVersion::GetTweakVersion())) { minTweak > cmVersion::GetTweakVersion())) {
std::ostringstream e; std::ostringstream e;
e << "An attempt was made to set the policy version of CMake to \"" e << "An attempt was made to set the policy version of CMake to \""
<< version_min << "\" which is greater than this version of CMake. " << version_min << "\" which is greater than this version of CMake. "
<< "This is not allowed because the greater version may have new " << "This is not allowed because the greater version may have new "
<< "policies not known to this CMake. " << "policies not known to this CMake. "
<< "You may need a newer CMake version to build this project."; << "You may need a newer CMake version to build this project.";
mf->IssueMessage(cmake::FATAL_ERROR, e.str()); mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
return false; return false;
} }
unsigned int polMajor = minMajor; unsigned int polMajor = minMajor;
unsigned int polMinor = minMinor; unsigned int polMinor = minMinor;
unsigned int polPatch = minPatch; unsigned int polPatch = minPatch;
if (!version_max.empty()) { if (!version_max.empty()) {
// Parse components of the maximum version. // Parse components of the maximum version.
unsigned int maxMajor = 0; unsigned int maxMajor = 0;
unsigned int maxMinor = 0; unsigned int maxMinor = 0;
unsigned int maxPatch = 0; unsigned int maxPatch = 0;
unsigned int maxTweak = 0; unsigned int maxTweak = 0;
if (sscanf(version_max.c_str(), "%u.%u.%u.%u", &maxMajor, &maxMinor, if (sscanf(version_max.c_str(), "%u.%u.%u.%u", &maxMajor, &maxMinor,
&maxPatch, &maxTweak) < 2) { &maxPatch, &maxTweak) < 2) {
std::ostringstream e; std::ostringstream e;
e << "Invalid policy max version value \"" << version_max << "\". " e << "Invalid policy max version value \"" << version_max << "\". "
<< "A numeric major.minor[.patch[.tweak]] must be given."; << "A numeric major.minor[.patch[.tweak]] must be given.";
mf->IssueMessage(cmake::FATAL_ERROR, e.str()); mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
return false; return false;
} }
// It is an error if the min version is greater than the max version. // It is an error if the min version is greater than the max version.
if (minMajor > maxMajor || (minMajor == maxMajor && minMinor > maxMinor) || if (minMajor > maxMajor || (minMajor == maxMajor && minMinor > maxMinor) ||
(minMajor == maxMajor && minMinor == maxMinor && (minMajor == maxMajor && minMinor == maxMinor &&
minPatch > maxPatch) || minPatch > maxPatch) ||
(minMajor == maxMajor && minMinor == maxMinor && (minMajor == maxMajor && minMinor == maxMinor &&
minPatch == maxPatch && minTweak > maxTweak)) { minPatch == maxPatch && minTweak > maxTweak)) {
std::ostringstream e; std::ostringstream e;
e << "Policy VERSION range \"" << version_min << "..." << version_max e << "Policy VERSION range \"" << version_min << "..." << version_max
<< "\"" << "\""
<< " specifies a larger minimum than maximum."; << " specifies a larger minimum than maximum.";
mf->IssueMessage(cmake::FATAL_ERROR, e.str()); mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
return false; return false;
} }
// Use the max version as the policy version. // Use the max version as the policy version.
polMajor = maxMajor; polMajor = maxMajor;
polMinor = maxMinor; polMinor = maxMinor;
polPatch = maxPatch; polPatch = maxPatch;
} }
return cmPolicies::ApplyPolicyVersion(mf, polMajor, polMinor, polPatch); return cmPolicies::ApplyPolicyVersion(mf, polMajor, polMinor, polPatch);
 End of changes. 9 change blocks. 
8 lines changed or deleted 8 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)