summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-04-07 21:14:41 (GMT)
committerBrad King <brad.king@kitware.com>2015-04-07 21:15:04 (GMT)
commit3347c5e4f9fcdd36c06067d6c7cd5a985a9c5d94 (patch)
treed0372265c5b1f07f9b1a8a6cc9bedf96bed2dbcb /Source/cmMakefile.cxx
parent9410e24a4ad3a21b2c27d057798f723e88d14d45 (diff)
downloadCMake-3347c5e4f9fcdd36c06067d6c7cd5a985a9c5d94.zip
CMake-3347c5e4f9fcdd36c06067d6c7cd5a985a9c5d94.tar.gz
CMake-3347c5e4f9fcdd36c06067d6c7cd5a985a9c5d94.tar.bz2
Revert topic 'refactor-cache-api'
This topic was never tested without some follow-up commits. The GetCacheEntryValue API returns a pointer to memory freed on return. It will have to be revised along with the rest of the original topic.
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r--Source/cmMakefile.cxx54
1 files changed, 32 insertions, 22 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 34b4621..215ee16 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -174,6 +174,16 @@ void cmMakefile::Initialize()
this->CheckCMP0000 = false;
}
+unsigned int cmMakefile::GetCacheMajorVersion() const
+{
+ return this->GetCacheManager()->GetCacheMajorVersion();
+}
+
+unsigned int cmMakefile::GetCacheMinorVersion() const
+{
+ return this->GetCacheManager()->GetCacheMinorVersion();
+}
+
cmMakefile::~cmMakefile()
{
cmDeleteAll(this->InstallGenerators);
@@ -1810,17 +1820,16 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value,
{
bool haveVal = value ? true : false;
std::string val = haveVal ? value : "";
- const char* existingValue =
- this->GetCacheManager()->GetInitializedCacheValue(name);
- if(existingValue
- && (this->GetCacheManager()->GetCacheEntryType(name)
- == cmCacheManager::UNINITIALIZED))
+ cmCacheManager::CacheIterator it =
+ this->GetCacheManager()->GetCacheIterator(name.c_str());
+ if(!it.IsAtEnd() && (it.GetType() == cmCacheManager::UNINITIALIZED) &&
+ it.Initialized())
{
// if this is not a force, then use the value from the cache
// if it is a force, then use the value being passed in
if(!force)
{
- val = existingValue;
+ val = it.GetValue();
haveVal = true;
}
if ( type == cmCacheManager::PATH || type == cmCacheManager::FILEPATH )
@@ -1843,13 +1852,13 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value,
}
this->GetCacheManager()->AddCacheEntry(name, nvalue.c_str(), doc, type);
- val = this->GetCacheManager()->GetInitializedCacheValue(name);
+ val = it.GetValue();
haveVal = true;
}
}
- this->GetCacheManager()->AddCacheEntry(name, haveVal ? val.c_str() : 0,
- doc, type);
+ this->GetCacheManager()->AddCacheEntry(name, haveVal ? val.c_str() : 0, doc,
+ type);
// if there was a definition then remove it
this->Internal->VarStack.top().Set(name, 0);
}
@@ -2433,7 +2442,7 @@ bool cmMakefile::IsDefinitionSet(const std::string& name) const
this->Internal->VarUsageStack.top().insert(name);
if(!def)
{
- def = this->GetCacheManager()->GetInitializedCacheValue(name);
+ def = this->GetCacheManager()->GetCacheValue(name);
}
#ifdef CMAKE_BUILD_WITH_CMAKE
if(cmVariableWatch* vv = this->GetVariableWatch())
@@ -2458,7 +2467,7 @@ const char* cmMakefile::GetDefinition(const std::string& name) const
const char* def = this->Internal->VarStack.top().Get(name);
if(!def)
{
- def = this->GetCacheManager()->GetInitializedCacheValue(name);
+ def = this->GetCacheManager()->GetCacheValue(name);
}
#ifdef CMAKE_BUILD_WITH_CMAKE
cmVariableWatch* vv = this->GetVariableWatch();
@@ -2492,18 +2501,20 @@ const char* cmMakefile::GetSafeDefinition(const std::string& def) const
std::vector<std::string> cmMakefile
::GetDefinitions(int cacheonly /* = 0 */) const
{
- std::vector<std::string> res;
+ std::set<std::string> definitions;
if ( !cacheonly )
{
- std::set<std::string> definitions =
- this->Internal->VarStack.top().ClosureKeys();
- res.insert(res.end(), definitions.begin(), definitions.end());
+ definitions = this->Internal->VarStack.top().ClosureKeys();
+ }
+ cmCacheManager::CacheIterator cit =
+ this->GetCacheManager()->GetCacheIterator();
+ for ( cit.Begin(); !cit.IsAtEnd(); cit.Next() )
+ {
+ definitions.insert(cit.GetName());
}
- std::vector<std::string> cacheKeys =
- this->GetCacheManager()->GetCacheEntryKeys();
- res.insert(res.end(), cacheKeys.begin(), cacheKeys.end());
- std::sort(res.begin(), res.end());
+ std::vector<std::string> res;
+ res.insert(res.end(), definitions.begin(), definitions.end());
return res;
}
@@ -2834,8 +2845,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
value = cmSystemTools::GetEnv(lookup.c_str());
break;
case CACHE:
- value = this->GetCacheManager()
- ->GetInitializedCacheValue(lookup);
+ value = this->GetCacheManager()->GetCacheValue(lookup);
break;
}
// Get the string we're meant to append to.
@@ -4903,7 +4913,7 @@ bool cmMakefile::SetPolicy(cmPolicies::PolicyID id,
(status == cmPolicies::WARN || status == cmPolicies::OLD))
{
if(!(this->GetCacheManager()
- ->GetInitializedCacheValue("CMAKE_BACKWARDS_COMPATIBILITY")))
+ ->GetCacheValue("CMAKE_BACKWARDS_COMPATIBILITY")))
{
// Set it to 2.4 because that is the last version where the
// variable had meaning.