summaryrefslogtreecommitdiffstats
path: root/Source/cmCacheManager.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2004-06-23 14:13:02 (GMT)
committerBrad King <brad.king@kitware.com>2004-06-23 14:13:02 (GMT)
commit4eb0400c9807bd984a9983dc993dbd47275b4d65 (patch)
treecabf980b14e3e6c17e3b74c5829dff857194250b /Source/cmCacheManager.cxx
parentf1842f913718f97cb53ff5e313ea0c99b97dc132 (diff)
downloadCMake-4eb0400c9807bd984a9983dc993dbd47275b4d65.zip
CMake-4eb0400c9807bd984a9983dc993dbd47275b4d65.tar.gz
CMake-4eb0400c9807bd984a9983dc993dbd47275b4d65.tar.bz2
ENH: Adding MODIFIED property to cache values that have been changed by the user.
Diffstat (limited to 'Source/cmCacheManager.cxx')
-rw-r--r--Source/cmCacheManager.cxx47
1 files changed, 47 insertions, 0 deletions
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx
index 01a3411..c48d485 100644
--- a/Source/cmCacheManager.cxx
+++ b/Source/cmCacheManager.cxx
@@ -244,6 +244,25 @@ bool cmCacheManager::LoadCache(const char* path,
}
it.SetProperty("ADVANCED", value.c_str());
}
+ else if ( e.m_Type == cmCacheManager::INTERNAL &&
+ (entryKey.size() > strlen("-MODIFIED")) &&
+ strcmp(entryKey.c_str() + (entryKey.size() - strlen("-MODIFIED")),
+ "-MODIFIED") == 0 )
+ {
+ std::string value = e.m_Value;
+ std::string akey = entryKey.substr(0, (entryKey.size() - strlen("-MODIFIED")));
+ cmCacheManager::CacheIterator it = this->GetCacheIterator(akey.c_str());
+ if ( it.IsAtEnd() )
+ {
+ e.m_Type = cmCacheManager::UNINITIALIZED;
+ m_Cache[akey] = e;
+ }
+ if (!it.Find(akey.c_str()))
+ {
+ cmSystemTools::Error("Internal CMake error when reading cache");
+ }
+ it.SetProperty("MODIFIED", value.c_str());
+ }
else
{
e.m_Initialized = true;
@@ -457,6 +476,34 @@ bool cmCacheManager::SaveCache(const char* path)
fout << key.c_str() << ":INTERNAL="
<< (i.GetPropertyAsBool("ADVANCED") ? "1" : "0") << "\n";
}
+ bool modified = i.PropertyExists("MODIFIED");
+ if ( modified )
+ {
+ // Format is key:type=value
+ std::string key;
+ std::string rkey = i.GetName();
+ std::string helpstring;
+ // If this is advanced variable, we have to do some magic for
+ // backward compatibility
+ helpstring = "Modified flag for variable: ";
+ helpstring += i.GetName();
+ rkey += "-MODIFIED";
+ cmCacheManager::OutputHelpString(fout, helpstring.c_str());
+ // support : in key name by double quoting
+ if(rkey.find(':') != std::string::npos ||
+ rkey.find("//") == 0)
+ {
+ key = "\"";
+ key += rkey;
+ key += "\"";
+ }
+ else
+ {
+ key = rkey;
+ }
+ fout << key.c_str() << ":INTERNAL="
+ << (i.GetPropertyAsBool("MODIFIED") ? "1" : "0") << "\n";
+ }
if(t == cmCacheManager::INTERNAL)
{
// Format is key:type=value