ENH: Provide variable CMAKE_VERSION

This creates the variable CMAKE_VERSION containing the full version of
cmake in "major.minor.patch" format.  It is particularly useful with the
component-wise version comparison provided by the if() command.
This commit is contained in:
Brad King 2009-01-15 08:57:44 -05:00
parent 004cdfe6ff
commit 35e391c93b
2 changed files with 13 additions and 0 deletions

View File

@ -214,6 +214,14 @@ void cmDocumentVariables::DefineVariables(cmake* cm)
"This specifies the patch version of the CMake" "This specifies the patch version of the CMake"
" executable being run.",false, " executable being run.",false,
"Variables that Provide Information"); "Variables that Provide Information");
cm->DefineProperty
("CMAKE_VERSION", cmProperty::VARIABLE,
"The full version of cmake in major.minor.patch format.",
"This specifies the full version of the CMake executable being run. "
"This variable is defined by versions 2.6.3 and higher. "
"See variables CMAKE_MAJOR_VERSION, CMAKE_MINOR_VERSION, and "
"CMAKE_PATCH_VERSION for individual version components.", false,
"Variables that Provide Information");
cm->DefineProperty cm->DefineProperty
("CMAKE_PARENT_LIST_FILE", cmProperty::VARIABLE, ("CMAKE_PARENT_LIST_FILE", cmProperty::VARIABLE,

View File

@ -2307,6 +2307,11 @@ void cmMakefile::AddDefaultDefinitions()
this->AddDefinition("CMAKE_MAJOR_VERSION", temp); this->AddDefinition("CMAKE_MAJOR_VERSION", temp);
sprintf(temp, "%d", cmVersion::GetPatchVersion()); sprintf(temp, "%d", cmVersion::GetPatchVersion());
this->AddDefinition("CMAKE_PATCH_VERSION", temp); this->AddDefinition("CMAKE_PATCH_VERSION", temp);
sprintf(temp, "%u.%u.%u",
cmVersion::GetMajorVersion(),
cmVersion::GetMinorVersion(),
cmVersion::GetPatchVersion());
this->AddDefinition("CMAKE_VERSION", temp);
this->AddDefinition("CMAKE_FILES_DIRECTORY", this->AddDefinition("CMAKE_FILES_DIRECTORY",
cmake::GetCMakeFilesDirectory()); cmake::GetCMakeFilesDirectory());