summaryrefslogtreecommitdiffstats
path: root/Source/cmCacheManager.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-01-24 12:37:08 (GMT)
committerBrad King <brad.king@kitware.com>2008-01-24 12:37:08 (GMT)
commit7213408287971b395bee21f9aeb59d1e393dc6a9 (patch)
tree883bb5b4ead553de734507e629eedf897bc99799 /Source/cmCacheManager.cxx
parentf5d86035f285816f174de6d0b14833f5b48d048b (diff)
downloadCMake-7213408287971b395bee21f9aeb59d1e393dc6a9.zip
CMake-7213408287971b395bee21f9aeb59d1e393dc6a9.tar.gz
CMake-7213408287971b395bee21f9aeb59d1e393dc6a9.tar.bz2
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.
Diffstat (limited to 'Source/cmCacheManager.cxx')
-rw-r--r--Source/cmCacheManager.cxx41
1 files changed, 38 insertions, 3 deletions
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx
index b1a7921..3eea333 100644
--- a/Source/cmCacheManager.cxx
+++ b/Source/cmCacheManager.cxx
@@ -320,10 +320,27 @@ bool cmCacheManager::LoadCache(const char* path,
". 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 @@ bool cmCacheManager::CacheIterator::PropertyExists(const char* property) const
}
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));
+}