diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index 08270375e..586070b87 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -18,7 +18,6 @@ #include "cmGlobalGenerator.h" #include #include "cmCTestTestHandler.h" -#include "cmCacheManager.h" //---------------------------------------------------------------------- cmCTestBuildAndTestHandler::cmCTestBuildAndTestHandler() @@ -255,7 +254,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) cm.SetGeneratorToolset(this->BuildGeneratorToolset); // Load the cache to make CMAKE_MAKE_PROGRAM available. - cm.GetCacheManager()->LoadCache(this->BinaryDir); + cm.LoadCache(this->BinaryDir); } else { diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index d60062e5b..1217bda19 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -639,7 +639,7 @@ int cmCursesMainForm::Configure(int noconfigure) // always save the current gui values to disk this->FillCacheManagerFromUI(); - this->CMakeInstance->GetCacheManager()->SaveCache( + this->CMakeInstance->SaveCache( this->CMakeInstance->GetHomeOutputDirectory()); this->LoadCache(0); diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index 996aa75fe..3df48d177 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -96,7 +96,7 @@ void QCMake::setBinaryDirectory(const QString& _dir) emit this->binaryDirChanged(this->BinaryDirectory); cmCacheManager *cachem = this->CMakeInstance->GetCacheManager(); this->setGenerator(QString()); - if(!this->CMakeInstance->GetCacheManager()->LoadCache( + if(!this->CMakeInstance->LoadCache( this->BinaryDirectory.toLocal8Bit().data())) { QDir testDir(this->BinaryDirectory); @@ -270,7 +270,7 @@ void QCMake::setProperties(const QCMakePropertyList& newProps) } } - cachem->SaveCache(this->BinaryDirectory.toLocal8Bit().data()); + this->CMakeInstance->SaveCache(this->BinaryDirectory.toLocal8Bit().data()); } QCMakePropertyList QCMake::properties() const @@ -397,9 +397,9 @@ QStringList QCMake::availableGenerators() const void QCMake::deleteCache() { // delete cache - this->CMakeInstance->GetCacheManager()->DeleteCache(this->BinaryDirectory.toLocal8Bit().data()); + this->CMakeInstance->DeleteCache(this->BinaryDirectory.toLocal8Bit().data()); // reload to make our cache empty - this->CMakeInstance->GetCacheManager()->LoadCache(this->BinaryDirectory.toLocal8Bit().data()); + this->CMakeInstance->LoadCache(this->BinaryDirectory.toLocal8Bit().data()); // emit no generator and no properties this->setGenerator(QString()); QCMakePropertyList props = this->properties(); @@ -412,7 +412,7 @@ void QCMake::reloadCache() QCMakePropertyList props; emit this->propertiesChanged(props); // reload - this->CMakeInstance->GetCacheManager()->LoadCache(this->BinaryDirectory.toLocal8Bit().data()); + this->CMakeInstance->LoadCache(this->BinaryDirectory.toLocal8Bit().data()); // emit new cache properties props = this->properties(); emit this->propertiesChanged(props); diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index df61fe6bf..1db057bd1 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -2281,7 +2281,7 @@ bool cmCTest::AddVariableDefinition(const std::string &arg) std::string value; cmCacheManager::CacheEntryType type = cmCacheManager::UNINITIALIZED; - if (cmCacheManager::ParseEntry(arg, name, value, type)) + if (cmake::ParseCacheEntry(arg, name, value, type)) { this->Definitions[name] = value; return true; diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index d64b0d74c..810ec57ee 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -223,7 +223,7 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout, mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(), cacheEntryName.c_str(), cmCacheManager::STRING, true); - mf->GetCacheManager()->SaveCache(mf->GetHomeOutputDirectory()); + mf->GetCMakeInstance()->SaveCache(mf->GetHomeOutputDirectory()); } else if (envVarValue==0 && cacheValue!=0) { @@ -244,7 +244,7 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout, mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(), cacheEntryName.c_str(), cmCacheManager::STRING, true); - mf->GetCacheManager()->SaveCache(mf->GetHomeOutputDirectory()); + mf->GetCMakeInstance()->SaveCache(mf->GetHomeOutputDirectory()); } } diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 5e584a452..0561a0542 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -3703,7 +3703,7 @@ cmGlobalXCodeGenerator::OutputXCodeProject(cmLocalGenerator* root, // Since this call may have created new cache entries, save the cache: // - root->GetMakefile()->GetCacheManager()->SaveCache( + root->GetMakefile()->GetCMakeInstance()->SaveCache( root->GetMakefile()->GetHomeOutputDirectory()); } diff --git a/Source/cmLoadCacheCommand.cxx b/Source/cmLoadCacheCommand.cxx index 93aec3220..e2ae90111 100644 --- a/Source/cmLoadCacheCommand.cxx +++ b/Source/cmLoadCacheCommand.cxx @@ -81,8 +81,8 @@ bool cmLoadCacheCommand { break; } - this->Makefile->GetCacheManager()->LoadCache(args[i], false, - excludes, includes); + this->Makefile->GetCMakeInstance()->LoadCache(args[i], false, + excludes, includes); } @@ -173,7 +173,7 @@ void cmLoadCacheCommand::CheckLine(const char* line) std::string var; std::string value; cmCacheManager::CacheEntryType type = cmCacheManager::UNINITIALIZED; - if(cmCacheManager::ParseEntry(line, var, value, type)) + if(cmake::ParseCacheEntry(line, var, value, type)) { // Found a real entry. See if this one was requested. if(this->VariablesToRead.find(var) != this->VariablesToRead.end()) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 5c52a1a2d..e78141799 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -917,7 +917,7 @@ void cmake::SetDirectoriesFromFile(const char* arg) { cmCacheManager* cachem = this->GetCacheManager(); cmCacheManager::CacheIterator it = cachem->NewIterator(); - if(cachem->LoadCache(cachePath) && + if(this->LoadCache(cachePath) && it.Find("CMAKE_HOME_DIRECTORY")) { this->SetHomeOutputDirectory(cachePath); @@ -1860,10 +1860,18 @@ void cmake::AddDefaultGenerators() #endif } +bool cmake::ParseCacheEntry(const std::string& entry, + std::string& var, + std::string& value, + cmCacheManager::CacheEntryType& type) +{ + return cmCacheManager::ParseEntry(entry, var, value, type); +} + int cmake::LoadCache() { // could we not read the cache - if (!this->CacheManager->LoadCache(this->GetHomeOutputDirectory())) + if (!this->LoadCache(this->GetHomeOutputDirectory())) { // if it does exist, but isn't readable then warn the user std::string cacheFile = this->GetHomeOutputDirectory(); @@ -1886,6 +1894,28 @@ int cmake::LoadCache() return 0; } +bool cmake::LoadCache(const std::string& path) +{ + return this->CacheManager->LoadCache(path); +} + +bool cmake::LoadCache(const std::string& path, bool internal, + std::set& excludes, + std::set& includes) +{ + return this->CacheManager->LoadCache(path, internal, excludes, includes); +} + +bool cmake::SaveCache(const std::string& path) +{ + return this->CacheManager->SaveCache(path); +} + +bool cmake::DeleteCache(const std::string& path) +{ + return this->CacheManager->DeleteCache(path); +} + void cmake::SetProgressCallback(ProgressCallbackType f, void *cd) { this->ProgressCallback = f; @@ -2764,9 +2794,8 @@ int cmake::Build(const std::string& dir, } std::string cachePath = dir; cmSystemTools::ConvertToUnixSlashes(cachePath); - cmCacheManager* cachem = this->GetCacheManager(); - cmCacheManager::CacheIterator it = cachem->NewIterator(); - if(!cachem->LoadCache(cachePath)) + cmCacheManager::CacheIterator it = this->GetCacheManager()->NewIterator(); + if(!this->LoadCache(cachePath)) { std::cerr << "Error: could not load cache\n"; return 1; diff --git a/Source/cmake.h b/Source/cmake.h index c22b329d7..3acf4a82f 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -18,11 +18,11 @@ #include "cmPropertyDefinitionMap.h" #include "cmPropertyMap.h" #include "cmInstalledFile.h" +#include "cmCacheManager.h" class cmGlobalGeneratorFactory; class cmGlobalGenerator; class cmLocalGenerator; -class cmCacheManager; class cmMakefile; class cmCommand; class cmVariableWatch; @@ -173,7 +173,19 @@ class cmake int Configure(); int ActualConfigure(); + ///! Break up a line like VAR:type="value" into var, type and value + static bool ParseCacheEntry(const std::string& entry, + std::string& var, + std::string& value, + cmCacheManager::CacheEntryType& type); + int LoadCache(); + bool LoadCache(const std::string& path); + bool LoadCache(const std::string& path, bool internal, + std::set& excludes, + std::set& includes); + bool SaveCache(const std::string& path); + bool DeleteCache(const std::string& path); void PreLoadCMakeFiles(); ///! Create a GlobalGenerator