[cmake-commits] king committed cmCacheManager.cxx 1.98 1.99
cmCacheManager.h 1.46 1.47 cmMakefile.cxx 1.429 1.430
cmMakefile.h 1.220 1.221
cmake-commits at cmake.org
cmake-commits at cmake.org
Thu Jan 24 07:37:10 EST 2008
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv6505/Source
Modified Files:
cmCacheManager.cxx cmCacheManager.h cmMakefile.cxx
cmMakefile.h
Log Message:
ENH: Added cmMakefile::NeedCacheCompatibility method and support for it in cmCacheManager. This will allow commands to modify their behavior when running with a cache loaded from an earlier CMake version.
Index: cmCacheManager.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmCacheManager.cxx,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -d -r1.98 -r1.99
--- cmCacheManager.cxx 7 Sep 2007 15:10:46 -0000 1.98
+++ cmCacheManager.cxx 24 Jan 2008 12:37:08 -0000 1.99
@@ -320,10 +320,27 @@
". Offending entry: ", realbuffer);
}
}
- // if CMAKE version not found in the list file
- // add them as version 0.0
- if(!this->GetCacheValue("CMAKE_CACHE_MINOR_VERSION"))
+ this->CacheMajorVersion = 0;
+ this->CacheMinorVersion = 0;
+ if(const char* cmajor = this->GetCacheValue("CMAKE_CACHE_MAJOR_VERSION"))
+ {
+ unsigned int v=0;
+ if(sscanf(cmajor, "%u", &v) == 1)
+ {
+ this->CacheMajorVersion = v;
+ }
+ if(const char* cminor = this->GetCacheValue("CMAKE_CACHE_MINOR_VERSION"))
+ {
+ if(sscanf(cminor, "%u", &v) == 1)
+ {
+ this->CacheMinorVersion = v;
+ }
+ }
+ }
+ else
{
+ // CMake version not found in the list file.
+ // Set as version 0.0
this->AddCacheEntry("CMAKE_CACHE_MINOR_VERSION", "0",
"Minor version of cmake used to create the "
"current loaded cache", cmCacheManager::INTERNAL);
@@ -950,3 +967,21 @@
}
return true;
}
+
+//----------------------------------------------------------------------------
+bool cmCacheManager::NeedCacheCompatibility(int major, int minor)
+{
+ // Compatibility is not needed if the cache version is zero because
+ // the cache was created or modified by the user.
+ if(this->CacheMajorVersion == 0)
+ {
+ return false;
+ }
+
+ // Compatibility is needed if the cache version is equal to or lower
+ // than the given version.
+ unsigned int actual_compat =
+ CMake_VERSION_ENCODE(this->CacheMajorVersion, this->CacheMinorVersion, 0);
+ return (actual_compat &&
+ actual_compat <= CMake_VERSION_ENCODE(major, minor, 0));
+}
Index: cmCacheManager.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmCacheManager.h,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- cmCacheManager.h 10 Apr 2007 20:03:10 -0000 1.46
+++ cmCacheManager.h 24 Jan 2008 12:37:08 -0000 1.47
@@ -142,6 +142,11 @@
///! Get a value from the cache given a key
const char* GetCacheValue(const char* key) const;
+ /** Get the version of CMake that wrote the cache. */
+ unsigned int GetCacheMajorVersion() { return this->CacheMajorVersion; }
+ unsigned int GetCacheMinorVersion() { return this->CacheMinorVersion; }
+ bool NeedCacheCompatibility(int major, int minor);
+
protected:
///! Add an entry into the cache
void AddCacheEntry(const char* key, const char* value,
@@ -154,7 +159,10 @@
CacheEntry *GetCacheEntry(const char *key);
///! Clean out the CMakeFiles directory if no CMakeCache.txt
void CleanCMakeFiles(const char* path);
-
+
+ // Cache version info
+ unsigned int CacheMajorVersion;
+ unsigned int CacheMinorVersion;
private:
typedef std::map<cmStdString, CacheEntry> CacheEntryMap;
static void OutputHelpString(std::ofstream& fout,
Index: cmMakefile.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.h,v
retrieving revision 1.220
retrieving revision 1.221
diff -u -d -r1.220 -r1.221
--- cmMakefile.h 23 Jan 2008 15:27:59 -0000 1.220
+++ cmMakefile.h 24 Jan 2008 12:37:08 -0000 1.221
@@ -58,6 +58,10 @@
*/
unsigned int GetCacheMajorVersion();
unsigned int GetCacheMinorVersion();
+
+ /** Return whether compatibility features needed for a version of
+ the cache or lower should be enabled. */
+ bool NeedCacheCompatibility(int major, int minor);
/**
* Construct an empty makefile.
Index: cmMakefile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.cxx,v
retrieving revision 1.429
retrieving revision 1.430
diff -u -d -r1.429 -r1.430
--- cmMakefile.cxx 23 Jan 2008 15:27:59 -0000 1.429
+++ cmMakefile.cxx 24 Jan 2008 12:37:08 -0000 1.430
@@ -145,32 +145,18 @@
unsigned int cmMakefile::GetCacheMajorVersion()
{
- if(const char* vstr =
- this->GetCacheManager()->GetCacheValue("CMAKE_CACHE_MAJOR_VERSION"))
- {
- unsigned int v=0;
- if(sscanf(vstr, "%u", &v) == 1)
- {
- return v;
- }
- }
- return 0;
+ return this->GetCacheManager()->GetCacheMajorVersion();
}
unsigned int cmMakefile::GetCacheMinorVersion()
{
- if(const char* vstr =
- this->GetCacheManager()->GetCacheValue("CMAKE_CACHE_MINOR_VERSION"))
- {
- unsigned int v=0;
- if(sscanf(vstr, "%u", &v) == 1)
- {
- return v;
- }
- }
- return 0;
+ return this->GetCacheManager()->GetCacheMinorVersion();
}
+bool cmMakefile::NeedCacheCompatibility(int major, int minor)
+{
+ return this->GetCacheManager()->NeedCacheCompatibility(major, minor);
+}
cmMakefile::~cmMakefile()
{
More information about the Cmake-commits
mailing list