diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index 4f272c9c4..a47bb220d 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -247,6 +247,7 @@ bool cmCacheManager::LoadCache(const char* path, } else { + e.m_Initialized = true; m_Cache[entryKey] = e; } } @@ -363,7 +364,7 @@ bool cmCacheManager::SaveCache(const char* path) { const CacheEntry& ce = (*i).second; CacheEntryType t = ce.m_Type; - if(t == cmCacheManager::UNINITIALIZED) + if(t == cmCacheManager::UNINITIALIZED || !ce.m_Initialized) { /* // This should be added in, but is not for now. @@ -423,6 +424,11 @@ bool cmCacheManager::SaveCache(const char* path) for( cmCacheManager::CacheIterator i = this->NewIterator(); !i.IsAtEnd(); i.Next()) { + if ( !i.Initialized() ) + { + continue; + } + CacheEntryType t = i.GetType(); bool advanced = i.PropertyExists("ADVANCED"); if ( advanced ) @@ -581,7 +587,8 @@ cmCacheManager::CacheIterator cmCacheManager::GetCacheIterator(const char *key) const char* cmCacheManager::GetCacheValue(const char* key) const { CacheEntryMap::const_iterator i = m_Cache.find(key); - if(i != m_Cache.end() && i->second.m_Type != cmCacheManager::UNINITIALIZED) + if(i != m_Cache.end() && i->second.m_Type != cmCacheManager::UNINITIALIZED && + i->second.m_Initialized) { return i->second.m_Value.c_str(); } @@ -616,10 +623,11 @@ void cmCacheManager::AddCacheEntry(const char* key, if ( value ) { e.m_Value = value; + e.m_Initialized = true; } else { - e.m_Value = "(none)"; + e.m_Value = ""; } e.m_Type = type; // make sure we only use unix style paths @@ -682,7 +690,15 @@ void cmCacheManager::CacheIterator::SetValue(const char* value) return; } CacheEntry* entry = &this->GetEntry(); - entry->m_Value = value; + if ( value ) + { + entry->m_Value = value; + entry->m_Initialized = true; + } + else + { + entry->m_Value = ""; + } } const char* cmCacheManager::CacheIterator::GetProperty(const char* property) const diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h index 6655997b8..8ad7d44f3 100644 --- a/Source/cmCacheManager.h +++ b/Source/cmCacheManager.h @@ -39,6 +39,9 @@ private: std::string m_Value; CacheEntryType m_Type; std::map m_Properties; + bool m_Initialized; + CacheEntry() : m_Value(""), m_Type(UNINITIALIZED), m_Initialized(false) + {} }; public: @@ -59,6 +62,7 @@ public: const char* GetValue() const { return this->GetEntry().m_Value.c_str(); } void SetValue(const char*); CacheEntryType GetType() const { return this->GetEntry().m_Type; } + bool Initialized() { return this->GetEntry().m_Initialized; } cmCacheManager &m_Container; std::map::iterator m_Position; CacheIterator(cmCacheManager &cm) : m_Container(cm) { diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 36997c66e..f61f7bf6b 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -842,7 +842,8 @@ void cmMakefile::AddCacheDefinition(const char* name, const char* value, const char* val = value; cmCacheManager::CacheIterator it = this->GetCacheManager()->GetCacheIterator(name); - if(!it.IsAtEnd() && (it.GetType() == cmCacheManager::UNINITIALIZED)) + if(!it.IsAtEnd() && (it.GetType() == cmCacheManager::UNINITIALIZED) && + it.Initialized()) { val = it.GetValue(); }