diff options
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r-- | Source/cmake.cxx | 609 |
1 files changed, 235 insertions, 374 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 51df7f2..a542a24 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -21,6 +21,7 @@ #include "cmTest.h" #include "cmDocumentationFormatter.h" #include "cmAlgorithms.h" +#include "cmState.h" #if defined(CMAKE_BUILD_WITH_CMAKE) # include "cmGraphVizWriter.h" @@ -133,7 +134,7 @@ cmake::cmake() this->FileComparison = new cmFileTimeComparison; this->Policies = new cmPolicies(); - this->InitializeProperties(); + this->State = new cmState(this); #ifdef __APPLE__ struct rlimit rlp; @@ -148,7 +149,6 @@ cmake::cmake() #endif this->Verbose = false; - this->InTryCompile = false; this->CacheManager = new cmCacheManager(this); this->GlobalGenerator = 0; this->ProgressCallback = 0; @@ -171,12 +171,12 @@ cmake::~cmake() { delete this->CacheManager; delete this->Policies; + delete this->State; if (this->GlobalGenerator) { delete this->GlobalGenerator; this->GlobalGenerator = 0; } - cmDeleteAll(this->Commands); cmDeleteAll(this->Generators); #ifdef CMAKE_BUILD_WITH_CMAKE delete this->VariableWatch; @@ -184,131 +184,10 @@ cmake::~cmake() delete this->FileComparison; } -void cmake::InitializeProperties() -{ - this->Properties.clear(); - this->Properties.SetCMakeInstance(this); - this->AccessedProperties.clear(); - this->PropertyDefinitions.clear(); - - // initialize properties - cmTarget::DefineProperties(this); - cmMakefile::DefineProperties(this); -} - void cmake::CleanupCommandsAndMacros() { - this->InitializeProperties(); - std::vector<cmCommand*> commands; - for(RegisteredCommandsMap::iterator j = this->Commands.begin(); - j != this->Commands.end(); ++j) - { - if ( !j->second->IsA("cmMacroHelperCommand") && - !j->second->IsA("cmFunctionHelperCommand")) - { - commands.push_back(j->second); - } - else - { - delete j->second; - } - } - this->Commands.erase(this->Commands.begin(), this->Commands.end()); - std::vector<cmCommand*>::iterator it; - for ( it = commands.begin(); it != commands.end(); - ++ it ) - { - this->Commands[cmSystemTools::LowerCase((*it)->GetName())] = *it; - } -} - -bool cmake::CommandExists(const std::string& name) const -{ - std::string sName = cmSystemTools::LowerCase(name); - return (this->Commands.find(sName) != this->Commands.end()); -} - -cmCommand *cmake::GetCommand(const std::string& name) -{ - cmCommand* rm = 0; - std::string sName = cmSystemTools::LowerCase(name); - RegisteredCommandsMap::iterator pos = this->Commands.find(sName); - if (pos != this->Commands.end()) - { - rm = (*pos).second; - } - return rm; -} - -void cmake::RenameCommand(const std::string& oldName, - const std::string& newName) -{ - // if the command already exists, free the old one - std::string sOldName = cmSystemTools::LowerCase(oldName); - std::string sNewName = cmSystemTools::LowerCase(newName); - RegisteredCommandsMap::iterator pos = this->Commands.find(sOldName); - if ( pos == this->Commands.end() ) - { - return; - } - cmCommand* cmd = pos->second; - - pos = this->Commands.find(sNewName); - if (pos != this->Commands.end()) - { - delete pos->second; - this->Commands.erase(pos); - } - this->Commands.insert(RegisteredCommandsMap::value_type(sNewName, cmd)); - pos = this->Commands.find(sOldName); - this->Commands.erase(pos); -} - -void cmake::RemoveCommand(const std::string& name) -{ - std::string sName = cmSystemTools::LowerCase(name); - RegisteredCommandsMap::iterator pos = this->Commands.find(sName); - if ( pos != this->Commands.end() ) - { - delete pos->second; - this->Commands.erase(pos); - } -} - -void cmake::AddCommand(cmCommand* wg) -{ - std::string name = cmSystemTools::LowerCase(wg->GetName()); - // if the command already exists, free the old one - RegisteredCommandsMap::iterator pos = this->Commands.find(name); - if (pos != this->Commands.end()) - { - delete pos->second; - this->Commands.erase(pos); - } - this->Commands.insert( RegisteredCommandsMap::value_type(name, wg)); -} - - -void cmake::RemoveUnscriptableCommands() -{ - std::vector<std::string> unscriptableCommands; - cmake::RegisteredCommandsMap* commands = this->GetCommands(); - for (cmake::RegisteredCommandsMap::const_iterator pos = commands->begin(); - pos != commands->end(); - ++pos) - { - if (!pos->second->IsScriptable()) - { - unscriptableCommands.push_back(pos->first); - } - } - - for(std::vector<std::string>::const_iterator it=unscriptableCommands.begin(); - it != unscriptableCommands.end(); - ++it) - { - this->RemoveCommand(*it); - } + this->State->Initialize(); + this->State->RemoveUserDefinedCommands(); } // Parse the args @@ -335,7 +214,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) } } std::string var, value; - cmCacheManager::CacheEntryType type = cmCacheManager::UNINITIALIZED; + cmState::CacheEntryType type = cmState::UNINITIALIZED; if(cmCacheManager::ParseEntry(entry, var, value, type)) { // The value is transformed if it is a filepath for example, so @@ -345,20 +224,20 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) std::string cachedValue; if(this->WarnUnusedCli) { - if(const char *v = this->CacheManager->GetCacheValue(var)) + if(const char *v = this->State->GetInitializedCacheValue(var)) { haveValue = true; cachedValue = v; } } - this->CacheManager->AddCacheEntry(var, value.c_str(), + this->State->AddCacheEntry(var, value.c_str(), "No help, variable specified on the command line.", type); if(this->WarnUnusedCli) { if (!haveValue || - cachedValue != this->CacheManager->GetCacheValue(var)) + cachedValue != this->State->GetInitializedCacheValue(var)) { this->WatchUnusedCli(var); } @@ -402,17 +281,16 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) cmsys::Glob::PatternToRegex(entryPattern, true, true).c_str()); //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() ) + std::vector<std::string> cacheKeys = this->State->GetCacheEntryKeys(); + for (std::vector<std::string>::const_iterator it = cacheKeys.begin(); + it != cacheKeys.end(); ++it) { - cmCacheManager::CacheEntryType t = it.GetType(); - if(t != cmCacheManager::STATIC) + cmState::CacheEntryType t = this->State->GetCacheEntryType(*it); + if(t != cmState::STATIC) { - std::string entryName = it.GetName(); - if (regex.find(entryName.c_str())) + if (regex.find(it->c_str())) { - entriesToDelete.push_back(entryName); + entriesToDelete.push_back(*it); } } } @@ -423,7 +301,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) currentEntry != entriesToDelete.end(); ++currentEntry) { - this->CacheManager->RemoveCacheEntry(*currentEntry); + this->State->RemoveCacheEntry(*currentEntry); } } else if(arg.find("-C",0) == 0) @@ -816,6 +694,7 @@ void cmake::SetArgs(const std::vector<std::string>& args, if(i >= args.size()) { cmSystemTools::Error("No generator specified for -G"); + this->PrintGeneratorList(); return; } value = args[i]; @@ -826,6 +705,7 @@ void cmake::SetArgs(const std::vector<std::string>& args, { cmSystemTools::Error("Could not create named generator ", value.c_str()); + this->PrintGeneratorList(); } else { @@ -843,12 +723,8 @@ void cmake::SetArgs(const std::vector<std::string>& args, { this->SetHomeOutputDirectory (cmSystemTools::GetCurrentWorkingDirectory()); - this->SetStartOutputDirectory - (cmSystemTools::GetCurrentWorkingDirectory()); this->SetHomeDirectory (cmSystemTools::GetCurrentWorkingDirectory()); - this->SetStartDirectory - (cmSystemTools::GetCurrentWorkingDirectory()); } this->SetStartDirectory(this->GetHomeDirectory()); @@ -916,16 +792,18 @@ void cmake::SetDirectoriesFromFile(const char* arg) // If there is a CMakeCache.txt file, use its settings. if(!cachePath.empty()) { - cmCacheManager* cachem = this->GetCacheManager(); - cmCacheManager::CacheIterator it = cachem->NewIterator(); - if(cachem->LoadCache(cachePath) && - it.Find("CMAKE_HOME_DIRECTORY")) + if(this->LoadCache(cachePath)) { - this->SetHomeOutputDirectory(cachePath); - this->SetStartOutputDirectory(cachePath); - this->SetHomeDirectory(it.GetValue()); - this->SetStartDirectory(it.GetValue()); - return; + const char* existingValue = + this->State->GetCacheEntryValue("CMAKE_HOME_DIRECTORY"); + if (existingValue) + { + this->SetHomeOutputDirectory(cachePath); + this->SetStartOutputDirectory(cachePath); + this->SetHomeDirectory(existingValue); + this->SetStartDirectory(existingValue); + return; + } } } @@ -971,14 +849,14 @@ int cmake::AddCMakePaths() // Save the value in the cache this->CacheManager->AddCacheEntry ("CMAKE_COMMAND", cmSystemTools::GetCMakeCommand().c_str(), - "Path to CMake executable.", cmCacheManager::INTERNAL); + "Path to CMake executable.", cmState::INTERNAL); #ifdef CMAKE_BUILD_WITH_CMAKE this->CacheManager->AddCacheEntry ("CMAKE_CTEST_COMMAND", cmSystemTools::GetCTestCommand().c_str(), - "Path to ctest program executable.", cmCacheManager::INTERNAL); + "Path to ctest program executable.", cmState::INTERNAL); this->CacheManager->AddCacheEntry ("CMAKE_CPACK_COMMAND", cmSystemTools::GetCPackCommand().c_str(), - "Path to cpack program executable.", cmCacheManager::INTERNAL); + "Path to cpack program executable.", cmState::INTERNAL); #endif if(!cmSystemTools::FileExists( (cmSystemTools::GetCMakeRoot()+"/Modules/CMake.cmake").c_str())) @@ -992,7 +870,7 @@ int cmake::AddCMakePaths() } this->CacheManager->AddCacheEntry ("CMAKE_ROOT", cmSystemTools::GetCMakeRoot().c_str(), - "Path to CMake installation.", cmCacheManager::INTERNAL); + "Path to CMake installation.", cmState::INTERNAL); return 1; } @@ -1110,12 +988,44 @@ void cmake::SetHomeDirectory(const std::string& dir) cmSystemTools::ConvertToUnixSlashes(this->cmHomeDirectory); } -void cmake::SetHomeOutputDirectory(const std::string& lib) +const char* cmake::GetHomeDirectory() const +{ + return this->cmHomeDirectory.c_str(); +} + +void cmake::SetHomeOutputDirectory(const std::string& dir) { - this->HomeOutputDirectory = lib; + this->HomeOutputDirectory = dir; cmSystemTools::ConvertToUnixSlashes(this->HomeOutputDirectory); } +const char* cmake::GetHomeOutputDirectory() const +{ + return this->HomeOutputDirectory.c_str(); +} + +const char* cmake::GetStartDirectory() const +{ + return this->cmStartDirectory.c_str(); +} + +void cmake::SetStartDirectory(const std::string& dir) +{ + this->cmStartDirectory = dir; + cmSystemTools::ConvertToUnixSlashes(this->cmStartDirectory); +} + +const char* cmake::GetStartOutputDirectory() const +{ + return this->StartOutputDirectory.c_str(); +} + +void cmake::SetStartOutputDirectory(const std::string& dir) +{ + this->StartOutputDirectory = dir; + cmSystemTools::ConvertToUnixSlashes(this->StartOutputDirectory); +} + void cmake::SetGlobalGenerator(cmGlobalGenerator *gg) { if(!gg) @@ -1204,10 +1114,10 @@ int cmake::DoPreConfigureChecks() } // do a sanity check on some values - if(this->CacheManager->GetCacheValue("CMAKE_HOME_DIRECTORY")) + if(this->CacheManager->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY")) { std::string cacheStart = - this->CacheManager->GetCacheValue("CMAKE_HOME_DIRECTORY"); + this->CacheManager->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY"); cacheStart += "/CMakeLists.txt"; std::string currentStart = this->GetHomeDirectory(); currentStart += "/CMakeLists.txt"; @@ -1234,7 +1144,7 @@ struct SaveCacheEntry std::string key; std::string value; std::string help; - cmCacheManager::CacheEntryType type; + cmState::CacheEntryType type; }; int cmake::HandleDeleteCacheVariables(const std::string& var) @@ -1242,12 +1152,12 @@ int cmake::HandleDeleteCacheVariables(const std::string& var) std::vector<std::string> argsSplit; cmSystemTools::ExpandListArgument(std::string(var), argsSplit, true); // erase the property to avoid infinite recursion - this->SetProperty("__CMAKE_DELETE_CACHE_CHANGE_VARS_", ""); - if(this->GetIsInTryCompile()) + this->State + ->SetGlobalProperty("__CMAKE_DELETE_CACHE_CHANGE_VARS_", ""); + if(this->State->GetIsInTryCompile()) { return 0; } - cmCacheManager::CacheIterator ci = this->CacheManager->NewIterator(); std::vector<SaveCacheEntry> saved; std::ostringstream warning; warning @@ -1263,10 +1173,13 @@ int cmake::HandleDeleteCacheVariables(const std::string& var) i++; save.value = *i; warning << *i << "\n"; - if(ci.Find(save.key)) + const char* existingValue = + this->CacheManager->GetCacheEntryValue(save.key); + if(existingValue) { - save.type = ci.GetType(); - if(const char* help = ci.GetProperty("HELPSTRING")) + save.type = this->CacheManager->GetCacheEntryType(save.key); + if(const char* help = + this->CacheManager->GetCacheEntryProperty(save.key, "HELPSTRING")) { save.help = help; } @@ -1305,7 +1218,7 @@ int cmake::Configure() AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", "TRUE", "Suppress Warnings that are meant for" " the author of the CMakeLists.txt files.", - cmCacheManager::INTERNAL); + cmState::INTERNAL); } else { @@ -1313,12 +1226,12 @@ int cmake::Configure() AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", "FALSE", "Suppress Warnings that are meant for" " the author of the CMakeLists.txt files.", - cmCacheManager::INTERNAL); + cmState::INTERNAL); } } int ret = this->ActualConfigure(); - const char* delCacheVars = - this->GetProperty("__CMAKE_DELETE_CACHE_CHANGE_VARS_"); + const char* delCacheVars = this->State + ->GetGlobalProperty("__CMAKE_DELETE_CACHE_CHANGE_VARS_"); if(delCacheVars && delCacheVars[0] != 0) { return this->HandleDeleteCacheVariables(delCacheVars); @@ -1349,16 +1262,16 @@ int cmake::ActualConfigure() this->GetHomeDirectory(), "Start directory with the top level CMakeLists.txt file for this " "project", - cmCacheManager::INTERNAL); + cmState::INTERNAL); } // no generator specified on the command line if(!this->GlobalGenerator) { const char* genName = - this->CacheManager->GetCacheValue("CMAKE_GENERATOR"); + this->CacheManager->GetInitializedCacheValue("CMAKE_GENERATOR"); const char* extraGenName = - this->CacheManager->GetCacheValue("CMAKE_EXTRA_GENERATOR"); + this->CacheManager->GetInitializedCacheValue("CMAKE_EXTRA_GENERATOR"); if(genName) { std::string fullName = cmExternalMakefileProjectGenerator:: @@ -1436,7 +1349,8 @@ int cmake::ActualConfigure() } } - const char* genName = this->CacheManager->GetCacheValue("CMAKE_GENERATOR"); + const char* genName = this->CacheManager + ->GetInitializedCacheValue("CMAKE_GENERATOR"); if(genName) { if(!this->GlobalGenerator->MatchesGeneratorName(genName)) @@ -1452,20 +1366,20 @@ int cmake::ActualConfigure() return -2; } } - if(!this->CacheManager->GetCacheValue("CMAKE_GENERATOR")) + if(!this->CacheManager->GetInitializedCacheValue("CMAKE_GENERATOR")) { this->CacheManager->AddCacheEntry("CMAKE_GENERATOR", this->GlobalGenerator->GetName().c_str(), "Name of generator.", - cmCacheManager::INTERNAL); + cmState::INTERNAL); this->CacheManager->AddCacheEntry("CMAKE_EXTRA_GENERATOR", this->GlobalGenerator->GetExtraGeneratorName().c_str(), "Name of external makefile project generator.", - cmCacheManager::INTERNAL); + cmState::INTERNAL); } if(const char* platformName = - this->CacheManager->GetCacheValue("CMAKE_GENERATOR_PLATFORM")) + this->CacheManager->GetInitializedCacheValue("CMAKE_GENERATOR_PLATFORM")) { if(this->GeneratorPlatform.empty()) { @@ -1489,11 +1403,11 @@ int cmake::ActualConfigure() this->CacheManager->AddCacheEntry("CMAKE_GENERATOR_PLATFORM", this->GeneratorPlatform.c_str(), "Name of generator platform.", - cmCacheManager::INTERNAL); + cmState::INTERNAL); } if(const char* tsName = - this->CacheManager->GetCacheValue("CMAKE_GENERATOR_TOOLSET")) + this->CacheManager->GetInitializedCacheValue("CMAKE_GENERATOR_TOOLSET")) { if(this->GeneratorToolset.empty()) { @@ -1517,20 +1431,16 @@ int cmake::ActualConfigure() this->CacheManager->AddCacheEntry("CMAKE_GENERATOR_TOOLSET", this->GeneratorToolset.c_str(), "Name of generator toolset.", - cmCacheManager::INTERNAL); + cmState::INTERNAL); } // reset any system configuration information, except for when we are // InTryCompile. With TryCompile the system info is taken from the parent's // info to save time - if (!this->InTryCompile) + if (!this->State->GetIsInTryCompile()) { this->GlobalGenerator->ClearEnabledLanguages(); - } - // Truncate log files - if (!this->InTryCompile) - { this->TruncateOutputLog("CMakeOutput.log"); this->TruncateOutputLog("CMakeError.log"); } @@ -1547,51 +1457,56 @@ int cmake::ActualConfigure() // project requires compatibility with CMake 2.4. We detect this // here by looking for the old CMAKE_BACKWARDS_COMPATIBILITY // variable created when CMP0001 is not set to NEW. - if(this->GetCacheManager()->GetCacheValue("CMAKE_BACKWARDS_COMPATIBILITY")) + if(this->State + ->GetInitializedCacheValue("CMAKE_BACKWARDS_COMPATIBILITY")) { - if(!this->CacheManager->GetCacheValue("LIBRARY_OUTPUT_PATH")) + if(!this->State->GetInitializedCacheValue("LIBRARY_OUTPUT_PATH")) { - this->CacheManager->AddCacheEntry + this->State->AddCacheEntry ("LIBRARY_OUTPUT_PATH", "", "Single output directory for building all libraries.", - cmCacheManager::PATH); + cmState::PATH); } - if(!this->CacheManager->GetCacheValue("EXECUTABLE_OUTPUT_PATH")) + if(!this->State + ->GetInitializedCacheValue("EXECUTABLE_OUTPUT_PATH")) { - this->CacheManager->AddCacheEntry + this->State->AddCacheEntry ("EXECUTABLE_OUTPUT_PATH", "", "Single output directory for building all executables.", - cmCacheManager::PATH); + cmState::PATH); } } - if(!this->CacheManager->GetCacheValue("CMAKE_USE_RELATIVE_PATHS")) + if(!this->State + ->GetInitializedCacheValue("CMAKE_USE_RELATIVE_PATHS")) { - this->CacheManager->AddCacheEntry + this->State->AddCacheEntry ("CMAKE_USE_RELATIVE_PATHS", "OFF", "If true, cmake will use relative paths in makefiles and projects.", - cmCacheManager::BOOL); - cmCacheManager::CacheIterator it = - this->CacheManager->GetCacheIterator("CMAKE_USE_RELATIVE_PATHS"); - if ( !it.PropertyExists("ADVANCED") ) + cmState::BOOL); + if (!this->State->GetCacheEntryProperty("CMAKE_USE_RELATIVE_PATHS", + "ADVANCED")) { - it.SetProperty("ADVANCED", "1"); + this->State->SetCacheEntryProperty("CMAKE_USE_RELATIVE_PATHS", + "ADVANCED", "1"); } } - if(cmSystemTools::GetFatalErrorOccured() && - (!this->CacheManager->GetCacheValue("CMAKE_MAKE_PROGRAM") || - cmSystemTools::IsOff(this->CacheManager-> - GetCacheValue("CMAKE_MAKE_PROGRAM")))) + if(cmSystemTools::GetFatalErrorOccured()) { - // We must have a bad generator selection. Wipe the cache entry so the - // user can select another. - this->CacheManager->RemoveCacheEntry("CMAKE_GENERATOR"); - this->CacheManager->RemoveCacheEntry("CMAKE_EXTRA_GENERATOR"); + const char* makeProgram = + this->State->GetInitializedCacheValue("CMAKE_MAKE_PROGRAM"); + if (!makeProgram || cmSystemTools::IsOff(makeProgram)) + { + // We must have a bad generator selection. Wipe the cache entry so the + // user can select another. + this->State->RemoveCacheEntry("CMAKE_GENERATOR"); + this->State->RemoveCacheEntry("CMAKE_EXTRA_GENERATOR"); + } } cmMakefile* mf=this->GlobalGenerator->GetLocalGenerators()[0]->GetMakefile(); if (mf->IsOn("CTEST_USE_LAUNCHERS") - && !this->GetProperty("RULE_LAUNCH_COMPILE", cmProperty::GLOBAL)) + && !this->State->GetGlobalProperty("RULE_LAUNCH_COMPILE")) { cmSystemTools::Error("CTEST_USE_LAUNCHERS is enabled, but the " "RULE_LAUNCH_COMPILE global property is not defined.\n" @@ -1792,24 +1707,24 @@ void cmake::AddCacheEntry(const std::string& key, const char* value, { this->CacheManager->AddCacheEntry(key, value, helpString, - cmCacheManager::CacheEntryType(type)); + cmState::CacheEntryType(type)); } const char* cmake::GetCacheDefinition(const std::string& name) const { - return this->CacheManager->GetCacheValue(name); + return this->CacheManager->GetInitializedCacheValue(name); } void cmake::AddDefaultCommands() { - std::list<cmCommand*> commands; + std::vector<cmCommand*> commands; GetBootstrapCommands1(commands); GetBootstrapCommands2(commands); GetPredefinedCommands(commands); - for(std::list<cmCommand*>::iterator i = commands.begin(); + for(std::vector<cmCommand*>::iterator i = commands.begin(); i != commands.end(); ++i) { - this->AddCommand(*i); + this->State->AddCommand(*i); } } @@ -1818,23 +1733,23 @@ void cmake::AddDefaultGenerators() #if defined(_WIN32) && !defined(__CYGWIN__) # if !defined(CMAKE_BOOT_MINGW) this->Generators.push_back( - cmGlobalVisualStudio6Generator::NewFactory()); - this->Generators.push_back( - cmGlobalVisualStudio7Generator::NewFactory()); + cmGlobalVisualStudio14Generator::NewFactory()); this->Generators.push_back( - cmGlobalVisualStudio10Generator::NewFactory()); + cmGlobalVisualStudio12Generator::NewFactory()); this->Generators.push_back( cmGlobalVisualStudio11Generator::NewFactory()); this->Generators.push_back( - cmGlobalVisualStudio12Generator::NewFactory()); + cmGlobalVisualStudio10Generator::NewFactory()); this->Generators.push_back( - cmGlobalVisualStudio14Generator::NewFactory()); + cmGlobalVisualStudio9Generator::NewFactory()); + this->Generators.push_back( + cmGlobalVisualStudio8Generator::NewFactory()); this->Generators.push_back( cmGlobalVisualStudio71Generator::NewFactory()); this->Generators.push_back( - cmGlobalVisualStudio8Generator::NewFactory()); + cmGlobalVisualStudio7Generator::NewFactory()); this->Generators.push_back( - cmGlobalVisualStudio9Generator::NewFactory()); + cmGlobalVisualStudio6Generator::NewFactory()); this->Generators.push_back( cmGlobalBorlandMakefileGenerator::NewFactory()); this->Generators.push_back( @@ -1861,10 +1776,18 @@ void cmake::AddDefaultGenerators() #endif } +bool cmake::ParseCacheEntry(const std::string& entry, + std::string& var, + std::string& value, + cmState::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(); @@ -1887,6 +1810,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<std::string>& excludes, + std::set<std::string>& 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; @@ -1895,13 +1840,23 @@ void cmake::SetProgressCallback(ProgressCallbackType f, void *cd) void cmake::UpdateProgress(const char *msg, float prog) { - if(this->ProgressCallback && !this->InTryCompile) + if(this->ProgressCallback && !this->State->GetIsInTryCompile()) { (*this->ProgressCallback)(msg, prog, this->ProgressCallbackClientData); return; } } +bool cmake::GetIsInTryCompile() const +{ + return this->State->GetIsInTryCompile(); +} + +void cmake::SetIsInTryCompile(bool b) +{ + this->State->SetIsInTryCompile(b); +} + void cmake::GetGeneratorDocumentation(std::vector<cmDocumentationEntry>& v) { for(RegisteredGeneratorsVector::const_iterator i = @@ -1923,11 +1878,24 @@ void cmake::GetGeneratorDocumentation(std::vector<cmDocumentationEntry>& v) } } +void cmake::PrintGeneratorList() +{ +#ifdef CMAKE_BUILD_WITH_CMAKE + cmDocumentation doc; + std::vector<cmDocumentationEntry> generators; + this->GetGeneratorDocumentation(generators); + doc.AppendSection("Generators",generators); + std::cerr << "\n"; + doc.PrintDocumentation(cmDocumentation::ListGenerators, std::cerr); +#endif +} + void cmake::UpdateConversionPathTable() { // Update the path conversion table with any specified file: const char* tablepath = - this->CacheManager->GetCacheValue("CMAKE_PATH_TRANSLATION_FILE"); + this->CacheManager + ->GetInitializedCacheValue("CMAKE_PATH_TRANSLATION_FILE"); if(tablepath) { @@ -2161,7 +2129,7 @@ void cmake::TruncateOutputLog(const char* fname) { return; } - if ( !this->CacheManager->GetCacheValue("CMAKE_CACHEFILE_DIR") ) + if (!this->State->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR")) { cmSystemTools::RemoveFile(fullPath); return; @@ -2209,136 +2177,25 @@ void cmake::GenerateGraphViz(const char* fileName) const #endif } -void cmake::DefineProperty(const std::string& name, - cmProperty::ScopeType scope, - const char *ShortDescription, - const char *FullDescription, - bool chained) -{ - this->PropertyDefinitions[scope].DefineProperty(name,scope,ShortDescription, - FullDescription, - chained); -} - -cmPropertyDefinition *cmake -::GetPropertyDefinition(const std::string& name, - cmProperty::ScopeType scope) -{ - if (this->IsPropertyDefined(name,scope)) - { - return &(this->PropertyDefinitions[scope][name]); - } - return 0; -} - -bool cmake::IsPropertyDefined(const std::string& name, - cmProperty::ScopeType scope) -{ - return this->PropertyDefinitions[scope].IsPropertyDefined(name); -} - -bool cmake::IsPropertyChained(const std::string& name, - cmProperty::ScopeType scope) -{ - return this->PropertyDefinitions[scope].IsPropertyChained(name); -} - void cmake::SetProperty(const std::string& prop, const char* value) { - // Special hook to invalidate cached value. - if(prop == "DEBUG_CONFIGURATIONS") - { - this->DebugConfigs.clear(); - } - - this->Properties.SetProperty(prop, value, cmProperty::GLOBAL); + this->State->SetGlobalProperty(prop, value); } void cmake::AppendProperty(const std::string& prop, const char* value, bool asString) { - // Special hook to invalidate cached value. - if(prop == "DEBUG_CONFIGURATIONS") - { - this->DebugConfigs.clear(); - } - - this->Properties.AppendProperty(prop, value, cmProperty::GLOBAL, asString); + this->State->AppendGlobalProperty(prop, value, asString); } const char *cmake::GetProperty(const std::string& prop) { - return this->GetProperty(prop, cmProperty::GLOBAL); -} - -const char *cmake::GetProperty(const std::string& prop, - cmProperty::ScopeType scope) -{ - bool chain = false; - - // watch for special properties - std::string output = ""; - if ( prop == "CACHE_VARIABLES" ) - { - cmCacheManager::CacheIterator cit = - this->GetCacheManager()->GetCacheIterator(); - for ( cit.Begin(); !cit.IsAtEnd(); cit.Next() ) - { - if (!output.empty()) - { - output += ";"; - } - output += cit.GetName(); - } - this->SetProperty("CACHE_VARIABLES", output.c_str()); - } - else if ( prop == "COMMANDS" ) - { - cmake::RegisteredCommandsMap::iterator cmds - = this->GetCommands()->begin(); - for (unsigned int cc=0 ; cmds != this->GetCommands()->end(); ++ cmds ) - { - if ( cc > 0 ) - { - output += ";"; - } - output += cmds->first.c_str(); - cc++; - } - this->SetProperty("COMMANDS",output.c_str()); - } - else if ( prop == "IN_TRY_COMPILE" ) - { - this->SetProperty("IN_TRY_COMPILE", - this->GetIsInTryCompile()? "1":"0"); - } - else if ( prop == "ENABLED_LANGUAGES" ) - { - std::string lang; - if(this->GlobalGenerator) - { - std::vector<std::string> enLangs; - this->GlobalGenerator->GetEnabledLanguages(enLangs); - lang = cmJoin(enLangs, ";"); - } - this->SetProperty("ENABLED_LANGUAGES", lang.c_str()); - } -#define STRING_LIST_ELEMENT(F) ";" #F - if (prop == "CMAKE_C_KNOWN_FEATURES") - { - return FOR_EACH_C_FEATURE(STRING_LIST_ELEMENT) + 1; - } - if (prop == "CMAKE_CXX_KNOWN_FEATURES") - { - return FOR_EACH_CXX_FEATURE(STRING_LIST_ELEMENT) + 1; - } -#undef STRING_LIST_ELEMENT - return this->Properties.GetPropertyValue(prop, scope, chain); + return this->State->GetGlobalProperty(prop); } bool cmake::GetPropertyAsBool(const std::string& prop) { - return cmSystemTools::IsOn(this->GetProperty(prop)); + return this->State->GetGlobalPropertyAsBool(prop); } cmInstalledFile *cmake::GetOrCreateInstalledFile( @@ -2408,6 +2265,7 @@ int cmake::GetSystemInformation(std::vector<std::string>& args) if(i >= args.size()) { cmSystemTools::Error("No generator specified for -G"); + this->PrintGeneratorList(); return -1; } value = args[i]; @@ -2418,6 +2276,7 @@ int cmake::GetSystemInformation(std::vector<std::string>& args) { cmSystemTools::Error("Could not create named generator ", value.c_str()); + this->PrintGeneratorList(); } else { @@ -2441,7 +2300,7 @@ int cmake::GetSystemInformation(std::vector<std::string>& args) // we have to find the module directory, so we can copy the files this->AddCMakePaths(); std::string modulesPath = - this->CacheManager->GetCacheValue("CMAKE_ROOT"); + this->State->GetInitializedCacheValue("CMAKE_ROOT"); modulesPath += "/Modules"; std::string inFile = modulesPath; inFile += "/SystemInformation.cmake"; @@ -2651,9 +2510,9 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text, if(t == cmake::AUTHOR_WARNING) { // Allow suppression of these warnings. - cmCacheManager::CacheIterator it = this->CacheManager - ->GetCacheIterator("CMAKE_SUPPRESS_DEVELOPER_WARNINGS"); - if(!it.IsAtEnd() && it.GetValueAsBool()) + const char* suppress = this->State->GetCacheEntryValue( + "CMAKE_SUPPRESS_DEVELOPER_WARNINGS"); + if(suppress && cmSystemTools::IsOn(suppress)) { return; } @@ -2729,27 +2588,25 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text, } //---------------------------------------------------------------------------- -std::vector<std::string> const& cmake::GetDebugConfigs() +std::vector<std::string> cmake::GetDebugConfigs() { - // Compute on-demand. - if(this->DebugConfigs.empty()) + std::vector<std::string> configs; + if(const char* config_list = + this->State->GetGlobalProperty("DEBUG_CONFIGURATIONS")) { - if(const char* config_list = this->GetProperty("DEBUG_CONFIGURATIONS")) - { - // Expand the specified list and convert to upper-case. - cmSystemTools::ExpandListArgument(config_list, this->DebugConfigs); - std::transform(this->DebugConfigs.begin(), - this->DebugConfigs.end(), - this->DebugConfigs.begin(), - cmSystemTools::UpperCase); - } - // If no configurations were specified, use a default list. - if(this->DebugConfigs.empty()) - { - this->DebugConfigs.push_back("DEBUG"); - } + // Expand the specified list and convert to upper-case. + cmSystemTools::ExpandListArgument(config_list, configs); + std::transform(configs.begin(), + configs.end(), + configs.begin(), + cmSystemTools::UpperCase); + } + // If no configurations were specified, use a default list. + if(configs.empty()) + { + configs.push_back("DEBUG"); } - return this->DebugConfigs; + return configs; } @@ -2766,38 +2623,42 @@ 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)) + if(!this->LoadCache(cachePath)) { std::cerr << "Error: could not load cache\n"; return 1; } - if(!it.Find("CMAKE_GENERATOR")) + const char* cachedGenerator = + this->State->GetCacheEntryValue("CMAKE_GENERATOR"); + if(!cachedGenerator) { std::cerr << "Error: could not find CMAKE_GENERATOR in Cache\n"; return 1; } cmsys::auto_ptr<cmGlobalGenerator> gen( - this->CreateGlobalGenerator(it.GetValue())); + this->CreateGlobalGenerator(cachedGenerator)); if(!gen.get()) { std::cerr << "Error: could create CMAKE_GENERATOR \"" - << it.GetValue() << "\"\n"; + << cachedGenerator << "\"\n"; return 1; } std::string output; std::string projName; - if(!it.Find("CMAKE_PROJECT_NAME")) + const char* cachedProjectName = + this->State->GetCacheEntryValue("CMAKE_PROJECT_NAME"); + if(!cachedProjectName) { std::cerr << "Error: could not find CMAKE_PROJECT_NAME in Cache\n"; return 1; } - projName = it.GetValue(); + projName = cachedProjectName; bool verbose = false; - if(it.Find("CMAKE_VERBOSE_MAKEFILE")) + const char* cachedVerbose = + this->State->GetCacheEntryValue("CMAKE_VERBOSE_MAKEFILE"); + if(cachedVerbose) { - verbose = it.GetValueAsBool(); + verbose = cmSystemTools::IsOn(cachedVerbose); } return gen->Build("", dir, projName, target, |