ENH: unify version stuff, get rid of it out of cmake and cmMakefile and only use cmVersion

This commit is contained in:
Bill Hoffman 2006-11-29 15:59:16 -05:00
parent 46f8ed0648
commit ccb77b65c6
11 changed files with 34 additions and 76 deletions

View File

@ -7,6 +7,7 @@
#undef DEBUG #undef DEBUG
#include "CMakeSetup.h" #include "CMakeSetup.h"
#include "MakeHelp.h" #include "MakeHelp.h"
#include "cmVersion.h"
#include "PathDialog.h" #include "PathDialog.h"
#include "CMakeSetupDialog.h" #include "CMakeSetupDialog.h"
#include "CMakeCommandLineInfo.h" #include "CMakeCommandLineInfo.h"
@ -323,8 +324,9 @@ BOOL CMakeSetupDialog::OnInitDialog()
// Set the version number // Set the version number
char tmp[1024]; char tmp[1024];
sprintf(tmp,"CMake %d.%d - %s", cmake::GetMajorVersion(), sprintf(tmp,"CMake %d.%d - %s", cmVersion::GetMajorVersion(),
cmake::GetMinorVersion(), cmake::GetReleaseVersion()); cmVersion::GetMinorVersion(),
cmVersion::GetReleaseVersion().c_str());
SetDlgItemText(IDC_PROGRESS, ""); SetDlgItemText(IDC_PROGRESS, "");
this->SetWindowText(tmp); this->SetWindowText(tmp);
this->UpdateData(FALSE); this->UpdateData(FALSE);

View File

@ -72,9 +72,9 @@ bool cmCMakeMinimumRequired::InitialPass(std::vector<std::string> const& args)
// Get the current version number. // Get the current version number.
int current_major = this->Makefile->GetMajorVersion(); int current_major = cmVersion::GetMajorVersion();
int current_minor = this->Makefile->GetMinorVersion(); int current_minor = cmVersion::GetMinorVersion();
int current_patch = this->Makefile->GetPatchVersion(); int current_patch = cmVersion::GetPatchVersion();
// Parse the required version number. If no patch-level is given // Parse the required version number. If no patch-level is given
// use zero. // use zero.

View File

@ -21,6 +21,7 @@
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmCPluginAPI.h" #include "cmCPluginAPI.h"
#include "cmVersion.h"
#include "cmSourceFile.h" #include "cmSourceFile.h"
@ -65,12 +66,12 @@ unsigned int CCONV cmGetCacheMinorVersion(void *arg)
unsigned int CCONV cmGetMajorVersion(void *) unsigned int CCONV cmGetMajorVersion(void *)
{ {
return cmMakefile::GetMajorVersion(); return cmVersion::GetMajorVersion();
} }
unsigned int CCONV cmGetMinorVersion(void *) unsigned int CCONV cmGetMinorVersion(void *)
{ {
return cmMakefile::GetMinorVersion(); return cmVersion::GetMinorVersion();
} }
void CCONV cmAddDefinition(void *arg, const char* name, const char* value) void CCONV cmAddDefinition(void *arg, const char* name, const char* value)

View File

@ -20,6 +20,7 @@
#include "cmCacheManager.h" #include "cmCacheManager.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmake.h" #include "cmake.h"
#include "cmVersion.h"
#include <cmsys/Directory.hxx> #include <cmsys/Directory.hxx>
#include <cmsys/Glob.hxx> #include <cmsys/Glob.hxx>
@ -370,17 +371,17 @@ bool cmCacheManager::SaveCache(const char* path)
// before writing the cache, update the version numbers // before writing the cache, update the version numbers
// to the // to the
char temp[1024]; char temp[1024];
sprintf(temp, "%d", cmMakefile::GetMinorVersion()); sprintf(temp, "%d", cmVersion::GetMinorVersion());
this->AddCacheEntry("CMAKE_CACHE_MINOR_VERSION", temp, this->AddCacheEntry("CMAKE_CACHE_MINOR_VERSION", temp,
"Minor version of cmake used to create the " "Minor version of cmake used to create the "
"current loaded cache", cmCacheManager::INTERNAL); "current loaded cache", cmCacheManager::INTERNAL);
sprintf(temp, "%d", cmMakefile::GetMajorVersion()); sprintf(temp, "%d", cmVersion::GetMajorVersion());
this->AddCacheEntry("CMAKE_CACHE_MAJOR_VERSION", temp, this->AddCacheEntry("CMAKE_CACHE_MAJOR_VERSION", temp,
"Major version of cmake used to create the " "Major version of cmake used to create the "
"current loaded cache", cmCacheManager::INTERNAL); "current loaded cache", cmCacheManager::INTERNAL);
this->AddCacheEntry("CMAKE_CACHE_RELEASE_VERSION", this->AddCacheEntry("CMAKE_CACHE_RELEASE_VERSION",
cmMakefile::GetReleaseVersion(), cmVersion::GetReleaseVersion().c_str(),
"Major version of cmake used to create the " "Major version of cmake used to create the "
"current loaded cache", cmCacheManager::INTERNAL); "current loaded cache", cmCacheManager::INTERNAL);

View File

@ -18,6 +18,7 @@
#include "cmLocalGenerator.h" #include "cmLocalGenerator.h"
#include "cmake.h" #include "cmake.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmVersion.h"
#include <stdlib.h> // required for atof #include <stdlib.h> // required for atof
@ -270,8 +271,8 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
// to avoid duplicate compiler tests. // to avoid duplicate compiler tests.
unsigned int cacheMajor = mf->GetCacheMajorVersion(); unsigned int cacheMajor = mf->GetCacheMajorVersion();
unsigned int cacheMinor = mf->GetCacheMinorVersion(); unsigned int cacheMinor = mf->GetCacheMinorVersion();
unsigned int selfMajor = cmMakefile::GetMajorVersion(); unsigned int selfMajor = cmVersion::GetMajorVersion();
unsigned int selfMinor = cmMakefile::GetMinorVersion(); unsigned int selfMinor = cmVersion::GetMinorVersion();
if((this->CMakeInstance->GetIsInTryCompile() || if((this->CMakeInstance->GetIsInTryCompile() ||
(selfMajor == cacheMajor && selfMinor == cacheMinor)) (selfMajor == cacheMajor && selfMinor == cacheMinor))
&& !mf->GetDefinition(loadedLang.c_str())) && !mf->GetDefinition(loadedLang.c_str()))

View File

@ -1643,7 +1643,6 @@ void cmLocalGenerator
{ {
continue; continue;
} }
// Link to a library if it is not the same target and is meant for // Link to a library if it is not the same target and is meant for
// this configuration type. // this configuration type.
if((target.GetType() == cmTarget::EXECUTABLE || if((target.GetType() == cmTarget::EXECUTABLE ||
@ -1664,7 +1663,6 @@ void cmLocalGenerator
linkItem += "/"; linkItem += "/";
linkItem += tgt->GetFullName(config); linkItem += tgt->GetFullName(config);
linkLibraries.push_back(linkItem); linkLibraries.push_back(linkItem);
// For full path, use the true location. // For full path, use the true location.
if(fullPathLibs) if(fullPathLibs)
{ {

View File

@ -23,6 +23,7 @@
#include "cmMakefileTargetGenerator.h" #include "cmMakefileTargetGenerator.h"
#include "cmSourceFile.h" #include "cmSourceFile.h"
#include "cmake.h" #include "cmake.h"
#include "cmVersion.h"
// Include dependency scanners for supported languages. Only the // Include dependency scanners for supported languages. Only the
// C/C++ scanner is needed for bootstrapping CMake. // C/C++ scanner is needed for bootstrapping CMake.
@ -1728,8 +1729,8 @@ void cmLocalUnixMakefileGenerator3::WriteDisclaimer(std::ostream& os)
<< "# CMAKE generated file: DO NOT EDIT!\n" << "# CMAKE generated file: DO NOT EDIT!\n"
<< "# Generated by \"" << this->GlobalGenerator->GetName() << "\"" << "# Generated by \"" << this->GlobalGenerator->GetName() << "\""
<< " Generator, CMake Version " << " Generator, CMake Version "
<< cmMakefile::GetMajorVersion() << "." << cmVersion::GetMajorVersion() << "."
<< cmMakefile::GetMinorVersion() << "\n\n"; << cmVersion::GetMinorVersion() << "\n\n";
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -15,7 +15,7 @@
=========================================================================*/ =========================================================================*/
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmVersion.h"
#include "cmCommand.h" #include "cmCommand.h"
#include "cmSourceFile.h" #include "cmSourceFile.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
@ -133,23 +133,6 @@ cmMakefile::cmMakefile(const cmMakefile& mf)
this->ListFileStack = mf.ListFileStack; this->ListFileStack = mf.ListFileStack;
} }
const char* cmMakefile::GetReleaseVersion()
{
#if CMake_VERSION_MINOR & 1
return "development";
#else
# if CMake_VERSION_PATCH == 1
return "1-beta";
# else
# ifdef CMake_VERSION_RC
return "patch " CMAKE_TO_STRING(CMake_VERSION_PATCH) " RC-"
CMAKE_TO_STRING(CMake_VERSION_RC);
# else
return "patch " CMAKE_TO_STRING(CMake_VERSION_PATCH);
# endif
# endif
#endif
}
unsigned int cmMakefile::GetCacheMajorVersion() unsigned int cmMakefile::GetCacheMajorVersion()
{ {
@ -1965,11 +1948,11 @@ void cmMakefile::AddDefaultDefinitions()
#endif #endif
char temp[1024]; char temp[1024];
sprintf(temp, "%d", cmMakefile::GetMinorVersion()); sprintf(temp, "%d", cmVersion::GetMinorVersion());
this->AddDefinition("CMAKE_MINOR_VERSION", temp); this->AddDefinition("CMAKE_MINOR_VERSION", temp);
sprintf(temp, "%d", cmMakefile::GetMajorVersion()); sprintf(temp, "%d", cmVersion::GetMajorVersion());
this->AddDefinition("CMAKE_MAJOR_VERSION", temp); this->AddDefinition("CMAKE_MAJOR_VERSION", temp);
sprintf(temp, "%d", cmMakefile::GetPatchVersion()); sprintf(temp, "%d", cmVersion::GetPatchVersion());
this->AddDefinition("CMAKE_PATCH_VERSION", temp); this->AddDefinition("CMAKE_PATCH_VERSION", temp);
this->AddDefinition("CMAKE_FILES_DIRECTORY", this->AddDefinition("CMAKE_FILES_DIRECTORY",

View File

@ -49,14 +49,6 @@ class cmake;
class cmMakefile class cmMakefile
{ {
public: public:
/**
* Return major and minor version numbers for cmake.
*/
static unsigned int GetMajorVersion() { return CMake_VERSION_MAJOR; }
static unsigned int GetMinorVersion() { return CMake_VERSION_MINOR; }
static unsigned int GetPatchVersion() { return CMake_VERSION_PATCH; }
static const char* GetReleaseVersion();
/** /**
* Return the major and minor version of the cmake that * Return the major and minor version of the cmake that
* was used to write the currently loaded cache, note * was used to write the currently loaded cache, note

View File

@ -1487,8 +1487,8 @@ int cmake::Configure()
if(!this->CacheManager->GetCacheValue("CMAKE_BACKWARDS_COMPATIBILITY")) if(!this->CacheManager->GetCacheValue("CMAKE_BACKWARDS_COMPATIBILITY"))
{ {
char ver[256]; char ver[256];
sprintf(ver,"%i.%i",cmMakefile::GetMajorVersion(), sprintf(ver,"%i.%i",cmVersion::GetMajorVersion(),
cmMakefile::GetMinorVersion()); cmVersion::GetMinorVersion());
this->CacheManager->AddCacheEntry this->CacheManager->AddCacheEntry
("CMAKE_BACKWARDS_COMPATIBILITY",ver, ("CMAKE_BACKWARDS_COMPATIBILITY",ver,
"For backwards compatibility, what version of CMake commands and " "For backwards compatibility, what version of CMake commands and "
@ -1680,10 +1680,10 @@ bool cmake::CacheVersionMatches()
this->CacheManager->GetCacheValue("CMAKE_CACHE_RELEASE_VERSION"); this->CacheManager->GetCacheValue("CMAKE_CACHE_RELEASE_VERSION");
bool cacheSameCMake = false; bool cacheSameCMake = false;
if(majv && if(majv &&
atoi(majv) == static_cast<int>(cmMakefile::GetMajorVersion()) atoi(majv) == static_cast<int>(cmVersion::GetMajorVersion())
&& minv && && minv &&
atoi(minv) == static_cast<int>(cmMakefile::GetMinorVersion()) atoi(minv) == static_cast<int>(cmVersion::GetMinorVersion())
&& relv && (strcmp(relv, cmMakefile::GetReleaseVersion()) == 0)) && relv && (strcmp(relv, cmVersion::GetReleaseVersion().c_str()) == 0))
{ {
cacheSameCMake = true; cacheSameCMake = true;
} }
@ -1815,21 +1815,6 @@ int cmake::Generate()
return 0; return 0;
} }
unsigned int cmake::GetMajorVersion()
{
return cmMakefile::GetMajorVersion();
}
unsigned int cmake::GetMinorVersion()
{
return cmMakefile::GetMinorVersion();
}
const char *cmake::GetReleaseVersion()
{
return cmMakefile::GetReleaseVersion();
}
void cmake::AddCacheEntry(const char* key, const char* value, void cmake::AddCacheEntry(const char* key, const char* value,
const char* helpString, const char* helpString,
int type) int type)
@ -1852,8 +1837,9 @@ int cmake::DumpDocumentationToFile(std::ostream& f)
const char *terse; const char *terse;
const char *full; const char *full;
char tmp[1024]; char tmp[1024];
sprintf(tmp,"Version %d.%d (%s)", cmake::GetMajorVersion(), sprintf(tmp,"Version %d.%d (%s)", cmVersion::GetMajorVersion(),
cmake::GetMinorVersion(), cmVersion::GetReleaseVersion().c_str()); cmVersion::GetMinorVersion(),
cmVersion::GetReleaseVersion().c_str());
f << "<html>\n"; f << "<html>\n";
f << "<h1>Documentation for commands of CMake " << tmp << "</h1>\n"; f << "<h1>Documentation for commands of CMake " << tmp << "</h1>\n";
f << "<ul>\n"; f << "<ul>\n";
@ -1959,8 +1945,8 @@ int cmake::LoadCache()
if(!this->CacheManager->GetCacheValue("CMAKE_BACKWARDS_COMPATIBILITY")) if(!this->CacheManager->GetCacheValue("CMAKE_BACKWARDS_COMPATIBILITY"))
{ {
char ver[256]; char ver[256];
sprintf(ver,"%i.%i",cmMakefile::GetMajorVersion(), sprintf(ver,"%i.%i",cmVersion::GetMajorVersion(),
cmMakefile::GetMinorVersion()); cmVersion::GetMinorVersion());
this->CacheManager->AddCacheEntry this->CacheManager->AddCacheEntry
("CMAKE_BACKWARDS_COMPATIBILITY",ver, ("CMAKE_BACKWARDS_COMPATIBILITY",ver,
"For backwards compatibility, what version of CMake commands and " "For backwards compatibility, what version of CMake commands and "

View File

@ -60,13 +60,6 @@ class cmake
///! destruct an instance of cmake ///! destruct an instance of cmake
~cmake(); ~cmake();
/**
* Return major and minor version numbers for cmake.
*/
static unsigned int GetMajorVersion();
static unsigned int GetMinorVersion();
static const char *GetReleaseVersion();
///! construct an instance of cmake ///! construct an instance of cmake
static const char *GetCMakeFilesDirectory() {return "/CMakeFiles";}; static const char *GetCMakeFilesDirectory() {return "/CMakeFiles";};
static const char *GetCMakeFilesDirectoryPostSlash() { static const char *GetCMakeFilesDirectoryPostSlash() {