mirror of
https://github.com/reactos/CMake.git
synced 2024-11-24 20:19:53 +00:00
ENH: Cleanup policy version interface presented to user.
- In cmake_minimum_required do not set policy version if current CMake is too old - In cmPolicies::ApplyPolicyVersion report error if version is too new or cannot be parsed
This commit is contained in:
parent
a24ff4e453
commit
1655dce2a5
@ -99,13 +99,12 @@ bool cmCMakeMinimumRequired
|
||||
{
|
||||
// The current version is too low.
|
||||
cmOStringStream e;
|
||||
e << "This project requires version " << version_string.c_str()
|
||||
<< " of CMake. "
|
||||
<< "You are running version "
|
||||
<< current_major << "." << current_minor << "." << current_patch
|
||||
<< ".\n";
|
||||
cmSystemTools::Error(e.str().c_str());
|
||||
e << "CMake " << version_string.c_str()
|
||||
<< " or higher is required. You are running version "
|
||||
<< current_major << "." << current_minor << "." << current_patch;
|
||||
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
||||
cmSystemTools::SetFatalErrorOccured();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (required_major < 2 || required_major == 2 && required_minor < 4)
|
||||
|
@ -117,13 +117,6 @@ cmCMakePolicyCommand::HandleVersionMode(std::vector<std::string> const& args)
|
||||
this->SetError("VERSION given too many arguments");
|
||||
return false;
|
||||
}
|
||||
if(!this->Makefile->SetPolicyVersion(args[1].c_str()))
|
||||
{
|
||||
cmOStringStream e;
|
||||
e << "VERSION given invalid value \"" << args[1] << "\". "
|
||||
<< "A numeric major.minor[.patch] must be given.";
|
||||
this->SetError(e.str().c_str());
|
||||
return false;
|
||||
}
|
||||
this->Makefile->SetPolicyVersion(args[1].c_str());
|
||||
return true;
|
||||
}
|
||||
|
@ -301,6 +301,10 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf,
|
||||
if(sscanf(ver.c_str(), "%u.%u.%u",
|
||||
&majorVer, &minorVer, &patchVer) < 2)
|
||||
{
|
||||
cmOStringStream e;
|
||||
e << "Invalid policy version value \"" << ver << "\". "
|
||||
<< "A numeric major.minor[.patch] must be given.";
|
||||
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -317,6 +321,26 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf,
|
||||
"CMAKE_BACKWARDS_COMPATIBILITY variable. "
|
||||
"One way to so this is to set the policy version to 2.4 exactly."
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 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() &&
|
||||
patchVer > cmVersion::GetPatchVersion()))
|
||||
{
|
||||
cmOStringStream e;
|
||||
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;
|
||||
}
|
||||
|
||||
// now loop over all the policies and set them as appropriate
|
||||
|
Loading…
Reference in New Issue
Block a user