summaryrefslogtreecommitdiffstats
path: root/Source/cmake.cxx
diff options
context:
space:
mode:
authorAlexander Neundorf <neundorf@kde.org>2007-06-01 18:16:46 (GMT)
committerAlexander Neundorf <neundorf@kde.org>2007-06-01 18:16:46 (GMT)
commit0be0283f30c58c82797579ca19cf0adf9b83dbad (patch)
tree3c40d8dcbdf37bd0990f771d709ddf0c3edb8b7d /Source/cmake.cxx
parentf94b8cfd3cf494d204db0d0454063b77197e2ec6 (diff)
downloadCMake-0be0283f30c58c82797579ca19cf0adf9b83dbad.zip
CMake-0be0283f30c58c82797579ca19cf0adf9b83dbad.tar.gz
CMake-0be0283f30c58c82797579ca19cf0adf9b83dbad.tar.bz2
BUG: also put a variable into the cache when defined using -D if no type is
given, then STRING is used. Also add command line option -U as suggested for undefining cache variables. This fixes #4896 and #4264. Alex
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r--Source/cmake.cxx49
1 files changed, 48 insertions, 1 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 973fc20..aae773f 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -299,7 +299,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
{
this->CacheManager->AddCacheEntry(var.c_str(), value.c_str(),
"No help, variable specified on the command line.",
- type);
+ type==cmCacheManager::UNINITIALIZED?cmCacheManager::STRING:type);
}
else
{
@@ -309,6 +309,49 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
return false;
}
}
+ else if(arg.find("-U",0) == 0)
+ {
+ std::string entryPattern = arg.substr(2);
+ if(entryPattern.size() == 0)
+ {
+ ++i;
+ if(i < args.size())
+ {
+ entryPattern = args[i];
+ }
+ else
+ {
+ cmSystemTools::Error("-U must be followed with VAR.");
+ return false;
+ }
+ }
+
+ //go through all cache entries and collect the vars which will be removed
+ std::vector<std::string> entriesToDelete;
+ cmCacheManager::CacheIterator it =
+ this->CacheManager->GetCacheIterator();
+ for ( it.Begin(); !it.IsAtEnd(); it.Next() )
+ {
+ cmCacheManager::CacheEntryType t = it.GetType();
+ if(t != cmCacheManager::STATIC && t != cmCacheManager::UNINITIALIZED)
+ {
+ std::string entryName = it.GetName();
+ if (entryName.find(entryPattern) != std::string::npos)
+ {
+ entriesToDelete.push_back(entryName);
+ }
+ }
+ }
+
+ // now remove them from the cache
+ for(std::vector<std::string>::const_iterator currentEntry =
+ entriesToDelete.begin();
+ currentEntry != entriesToDelete.end();
+ ++currentEntry)
+ {
+ this->CacheManager->RemoveCacheEntry(currentEntry->c_str());
+ }
+ }
else if(arg.find("-C",0) == 0)
{
std::string path = arg.substr(2);
@@ -432,6 +475,10 @@ void cmake::SetArgs(const std::vector<std::string>& args)
{
// skip for now
}
+ else if(arg.find("-U",0) == 0)
+ {
+ // skip for now
+ }
else if(arg.find("-C",0) == 0)
{
// skip for now