Teach cmake_minimum_required about tweak version

The command now accepts four version components in the format

  major[.minor[.patch[.tweak]]]

This corresponds to the new versioning scheme introduced recently.
This commit is contained in:
Brad King 2010-04-23 09:50:02 -04:00
parent 5bfffd6f29
commit 378acb1d4d
2 changed files with 15 additions and 8 deletions

View File

@ -66,14 +66,17 @@ bool cmCMakeMinimumRequired
int current_major = cmVersion::GetMajorVersion(); int current_major = cmVersion::GetMajorVersion();
int current_minor = cmVersion::GetMinorVersion(); int current_minor = cmVersion::GetMinorVersion();
int current_patch = cmVersion::GetPatchVersion(); int current_patch = cmVersion::GetPatchVersion();
int current_tweak = cmVersion::GetTweakVersion();
// Parse the required version number. If no patch-level is given // Parse at least two components of the version number.
// use zero. // Use zero for those not specified.
int required_major = 0; int required_major = 0;
int required_minor = 0; int required_minor = 0;
int required_patch = 0; int required_patch = 0;
if(sscanf(version_string.c_str(), "%d.%d.%d", int required_tweak = 0;
&required_major, &required_minor, &required_patch) < 2) if(sscanf(version_string.c_str(), "%u.%u.%u.%u",
&required_major, &required_minor,
&required_patch, &required_tweak) < 2)
{ {
cmOStringStream e; cmOStringStream e;
e << "could not parse VERSION \"" << version_string.c_str() << "\"."; e << "could not parse VERSION \"" << version_string.c_str() << "\".";
@ -87,13 +90,17 @@ bool cmCMakeMinimumRequired
current_minor < required_minor) || current_minor < required_minor) ||
(current_major == required_major && (current_major == required_major &&
current_minor == required_minor && current_minor == required_minor &&
current_patch < required_patch)) current_patch < required_patch) ||
(current_major == required_major &&
current_minor == required_minor &&
current_patch == required_patch &&
current_tweak < required_tweak))
{ {
// The current version is too low. // The current version is too low.
cmOStringStream e; cmOStringStream e;
e << "CMake " << version_string.c_str() e << "CMake " << version_string.c_str()
<< " or higher is required. You are running version " << " or higher is required. You are running version "
<< current_major << "." << current_minor << "." << current_patch; << cmVersion::GetCMakeVersion();
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
cmSystemTools::SetFatalErrorOccured(); cmSystemTools::SetFatalErrorOccured();
return true; return true;

View File

@ -61,13 +61,13 @@ public:
virtual const char* GetFullDocumentation() virtual const char* GetFullDocumentation()
{ {
return return
" cmake_minimum_required(VERSION major[.minor[.patch]]\n" " cmake_minimum_required(VERSION major[.minor[.patch[.tweak]]]\n"
" [FATAL_ERROR])\n" " [FATAL_ERROR])\n"
"If the current version of CMake is lower than that required " "If the current version of CMake is lower than that required "
"it will stop processing the project and report an error. " "it will stop processing the project and report an error. "
"When a version higher than 2.4 is specified the command implicitly " "When a version higher than 2.4 is specified the command implicitly "
"invokes\n" "invokes\n"
" cmake_policy(VERSION major[.minor[.patch]])\n" " cmake_policy(VERSION major[.minor[.patch[.tweak]]])\n"
"which sets the cmake policy version level to the version specified. " "which sets the cmake policy version level to the version specified. "
"When version 2.4 or lower is given the command implicitly invokes\n" "When version 2.4 or lower is given the command implicitly invokes\n"
" cmake_policy(VERSION 2.4)\n" " cmake_policy(VERSION 2.4)\n"