diff options
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r-- | Source/cmake.cxx | 169 |
1 files changed, 101 insertions, 68 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx index b1eea98..8cdf96f 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -191,7 +191,6 @@ cmake::~cmake() void cmake::InitializeProperties() { this->Properties.clear(); - this->Properties.SetCMakeInstance(this); this->PropertyDefinitions.clear(); // initialize properties @@ -227,20 +226,19 @@ void cmake::CleanupCommandsAndMacros() bool cmake::CommandExists(const std::string& name) const { - std::string sName = cmSystemTools::LowerCase(name); - return (this->Commands.find(sName) != this->Commands.end()); + return this->GetCommand(name) ? true : false; } -cmCommand *cmake::GetCommand(const std::string& name) +cmCommand *cmake::GetCommand(const std::string& name) const { - cmCommand* rm = 0; + cmCommand* command = 0; std::string sName = cmSystemTools::LowerCase(name); - RegisteredCommandsMap::iterator pos = this->Commands.find(sName); + RegisteredCommandsMap::const_iterator pos = this->Commands.find(sName); if (pos != this->Commands.end()) { - rm = (*pos).second; + command = (*pos).second; } - return rm; + return command; } void cmake::RenameCommand(const std::string& oldName, @@ -248,12 +246,12 @@ void cmake::RenameCommand(const std::string& oldName, { // 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; } + std::string sNewName = cmSystemTools::LowerCase(newName); cmCommand* cmd = pos->second; pos = this->Commands.find(sNewName); @@ -262,7 +260,7 @@ void cmake::RenameCommand(const std::string& oldName, delete pos->second; this->Commands.erase(pos); } - this->Commands.insert(RegisteredCommandsMap::value_type(sNewName, cmd)); + this->Commands.insert(std::make_pair(sNewName, cmd)); pos = this->Commands.find(sOldName); this->Commands.erase(pos); } @@ -278,9 +276,9 @@ void cmake::RemoveCommand(const std::string& name) } } -void cmake::AddCommand(cmCommand* wg) +void cmake::AddCommand(cmCommand* command) { - std::string name = cmSystemTools::LowerCase(wg->GetName()); + std::string name = cmSystemTools::LowerCase(command->GetName()); // if the command already exists, free the old one RegisteredCommandsMap::iterator pos = this->Commands.find(name); if (pos != this->Commands.end()) @@ -288,16 +286,16 @@ void cmake::AddCommand(cmCommand* wg) delete pos->second; this->Commands.erase(pos); } - this->Commands.insert( RegisteredCommandsMap::value_type(name, wg)); + this->Commands.insert(std::make_pair(name, command)); } void cmake::RemoveUnscriptableCommands() { std::vector<std::string> unscriptableCommands; - cmake::RegisteredCommandsMap* commands = this->GetCommands(); - for (cmake::RegisteredCommandsMap::const_iterator pos = commands->begin(); - pos != commands->end(); + for (cmake::RegisteredCommandsMap::const_iterator + pos = this->Commands.begin(); + pos != this->Commands.end(); ++pos) { if (!pos->second->IsScriptable()) @@ -818,6 +816,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]; @@ -828,6 +827,7 @@ void cmake::SetArgs(const std::vector<std::string>& args, { cmSystemTools::Error("Could not create named generator ", value.c_str()); + this->PrintGeneratorList(); } else { @@ -845,12 +845,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()); @@ -1114,12 +1110,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) @@ -1533,11 +1561,7 @@ int cmake::ActualConfigure() if (!this->InTryCompile) { this->GlobalGenerator->ClearEnabledLanguages(); - } - // Truncate log files - if (!this->InTryCompile) - { this->TruncateOutputLog("CMakeOutput.log"); this->TruncateOutputLog("CMakeError.log"); } @@ -1814,11 +1838,11 @@ const char* cmake::GetCacheDefinition(const std::string& name) const 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); @@ -1830,23 +1854,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( @@ -1944,6 +1968,16 @@ void cmake::UpdateProgress(const char *msg, float prog) } } +bool cmake::GetIsInTryCompile() const +{ + return this->InTryCompile; +} + +void cmake::SetIsInTryCompile(bool b) +{ + this->InTryCompile = b; +} + void cmake::GetGeneratorDocumentation(std::vector<cmDocumentationEntry>& v) { for(RegisteredGeneratorsVector::const_iterator i = @@ -1965,6 +1999,18 @@ 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: @@ -2288,24 +2334,12 @@ bool cmake::IsPropertyChained(const std::string& 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); } 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); } @@ -2327,8 +2361,8 @@ const char *cmake::GetProperty(const std::string& prop, else if ( prop == "COMMANDS" ) { cmake::RegisteredCommandsMap::iterator cmds - = this->GetCommands()->begin(); - for (unsigned int cc=0 ; cmds != this->GetCommands()->end(); ++ cmds ) + = this->Commands.begin(); + for (unsigned int cc=0 ; cmds != this->Commands.end(); ++ cmds ) { if ( cc > 0 ) { @@ -2441,6 +2475,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]; @@ -2451,6 +2486,7 @@ int cmake::GetSystemInformation(std::vector<std::string>& args) { cmSystemTools::Error("Could not create named generator ", value.c_str()); + this->PrintGeneratorList(); } else { @@ -2762,27 +2798,24 @@ 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->GetProperty("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; } |