summaryrefslogtreecommitdiffstats
path: root/Source/cmake.cxx
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2007-12-13 20:54:29 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2007-12-13 20:54:29 (GMT)
commitfd33bf93a5e9d86ee249cc3fde22a221dfe861e8 (patch)
tree1704ac68da40c79e84d9598b5b4d7b816637d86b /Source/cmake.cxx
parent3409e0a777a5ae0306e2165bc518f60a5281b8ca (diff)
downloadCMake-fd33bf93a5e9d86ee249cc3fde22a221dfe861e8.zip
CMake-fd33bf93a5e9d86ee249cc3fde22a221dfe861e8.tar.gz
CMake-fd33bf93a5e9d86ee249cc3fde22a221dfe861e8.tar.bz2
ENH: fix for bug 6102, allow users to change the compiler
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r--Source/cmake.cxx73
1 files changed, 71 insertions, 2 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 4eb92ad..6b89319 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -224,7 +224,7 @@ void cmake::CleanupCommandsAndMacros()
for(RegisteredCommandsMap::iterator j = this->Commands.begin();
j != this->Commands.end(); ++j)
{
- if ( !j->second->IsA("cmMacroHelperCommand") &&
+ if ( !j->second->IsA("cmMacroHelpperCommand") &&
!j->second->IsA("cmFunctionHelperCommand"))
{
commands.push_back(j->second);
@@ -1793,9 +1793,79 @@ int cmake::DoPreConfigureChecks()
}
return 1;
}
+struct SaveCacheEntry
+{
+ std::string key;
+ std::string value;
+ std::string help;
+ cmCacheManager::CacheEntryType type;
+};
+
+int cmake::HandleDeleteCacheVariables(const char* var)
+{
+ std::vector<std::string> argsSplit;
+ cmSystemTools::ExpandListArgument(std::string(var), argsSplit);
+ // erase the property to avoid infinite recursion
+ this->SetProperty("__CMAKE_DELETE_CACHE_CHANGE_VARS_", "");
+
+ cmCacheManager::CacheIterator ci = this->CacheManager->NewIterator();
+ std::vector<SaveCacheEntry> saved;
+ cmOStringStream warning;
+ warning
+ << "You have changed variables that require your cache to be deleted.\n"
+ << "Configure will be re-run and you may have to reset some variables.\n"
+ << "The following variables have changed:\n";
+ for(std::vector<std::string>::iterator i = argsSplit.begin();
+ i != argsSplit.end(); ++i)
+ {
+ SaveCacheEntry save;
+ save.key = *i;
+ warning << *i << "= ";
+ i++;
+ save.value = *i;
+ warning << *i << "\n";
+ if(ci.Find(save.key.c_str()))
+ {
+ save.type = ci.GetType();
+ save.help = ci.GetProperty("HELPSTRING");
+ }
+ saved.push_back(save);
+ }
+
+ // remove the cache
+ this->CacheManager->DeleteCache(this->GetStartOutputDirectory());
+ // load the empty cache
+ this->LoadCache();
+ // restore the changed compilers
+ for(std::vector<SaveCacheEntry>::iterator i = saved.begin();
+ i != saved.end(); ++i)
+ {
+ this->AddCacheEntry(i->key.c_str(), i->value.c_str(),
+ i->help.c_str(), i->type);
+ }
+ cmSystemTools::Message(warning.str().c_str());
+ // avoid reconfigure if there were errors
+ if(!cmSystemTools::GetErrorOccuredFlag())
+ {
+ // re-run configure
+ return this->Configure();
+ }
+}
int cmake::Configure()
{
+ int ret = this->ActualConfigure();
+ const char* delCacheVars = this->GetProperty("__CMAKE_DELETE_CACHE_CHANGE_VARS_");
+ if(delCacheVars && delCacheVars[0] != 0)
+ {
+ return this->HandleDeleteCacheVariables(delCacheVars);
+ }
+ return ret;
+
+}
+
+int cmake::ActualConfigure()
+{
// Construct right now our path conversion table before it's too late:
this->UpdateConversionPathTable();
this->CleanupCommandsAndMacros();
@@ -1955,7 +2025,6 @@ int cmake::Configure()
// actually do the configure
this->GlobalGenerator->Configure();
-
// Before saving the cache
// if the project did not define one of the entries below, add them now
// so users can edit the values in the cache: