diff options
Diffstat (limited to 'Source/cmLocalGenerator.cxx')
-rw-r--r-- | Source/cmLocalGenerator.cxx | 194 |
1 files changed, 118 insertions, 76 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 3230403..8a76c21 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -132,12 +132,11 @@ void cmLocalGenerator::TraceDependencies() this->GlobalGenerator->CreateEvaluationSourceFiles(*ci); } // Generate the rule files for each target. - cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets(); + cmGeneratorTargetsType targets = this->GetGeneratorTargets(); for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { - if (t->second->Target->IsImported() - || t->second->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + if (t->second->GetType() == cmState::INTERFACE_LIBRARY) { continue; } @@ -448,6 +447,12 @@ void cmLocalGenerator::GenerateInstallRules() } } + +void cmLocalGenerator::AddGeneratorTarget(cmTarget* t, cmGeneratorTarget* gt) +{ + this->GeneratorTargets[t] = gt; +} + //---------------------------------------------------------------------------- void cmLocalGenerator::ComputeTargetManifest() { @@ -460,16 +465,12 @@ void cmLocalGenerator::ComputeTargetManifest() } // Add our targets to the manifest for each configuration. - cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets(); + cmGeneratorTargetsType targets = this->GetGeneratorTargets(); for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { cmGeneratorTarget& target = *t->second; - if (target.Target->GetType() == cmTarget::INTERFACE_LIBRARY) - { - continue; - } - if (target.Target->IsImported()) + if (target.GetType() == cmState::INTERFACE_LIBRARY) { continue; } @@ -753,7 +754,7 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, } if(variable == "TARGET_TYPE") { - return cmTarget::GetTargetTypeName(replaceValues.CMTarget->GetType()); + return cmState::GetTargetTypeName(replaceValues.CMTarget->GetType()); } } if(replaceValues.Output) @@ -913,7 +914,7 @@ cmLocalGenerator::ExpandRuleVariables(std::string& s, } //---------------------------------------------------------------------------- -const char* cmLocalGenerator::GetRuleLauncher(cmTarget* target, +const char* cmLocalGenerator::GetRuleLauncher(cmGeneratorTarget* target, const std::string& prop) { if(target) @@ -927,7 +928,8 @@ const char* cmLocalGenerator::GetRuleLauncher(cmTarget* target, } //---------------------------------------------------------------------------- -void cmLocalGenerator::InsertRuleLauncher(std::string& s, cmTarget* target, +void cmLocalGenerator::InsertRuleLauncher(std::string& s, + cmGeneratorTarget* target, const std::string& prop) { if(const char* val = this->GetRuleLauncher(target, prop)) @@ -1080,27 +1082,23 @@ std::string cmLocalGenerator::GetIncludeFlags( //---------------------------------------------------------------------------- void cmLocalGenerator::AddCompileDefinitions(std::set<std::string>& defines, - cmTarget const* target, + cmGeneratorTarget const* target, const std::string& config, const std::string& lang) { std::vector<std::string> targetDefines; - cmGeneratorTarget* gtgt = this->GlobalGenerator->GetGeneratorTarget(target); - gtgt->GetCompileDefinitions(targetDefines, config, lang); + target->GetCompileDefinitions(targetDefines, config, lang); this->AppendDefines(defines, targetDefines); } //---------------------------------------------------------------------------- void cmLocalGenerator::AddCompileOptions( - std::string& flags, cmTarget* target, + std::string& flags, cmGeneratorTarget* target, const std::string& lang, const std::string& config ) { std::string langFlagRegexVar = std::string("CMAKE_")+lang+"_FLAG_REGEX"; - cmGeneratorTarget* gtgt = - this->GlobalGenerator->GetGeneratorTarget(target); - if(const char* langFlagRegexStr = this->Makefile->GetDefinition(langFlagRegexVar)) { @@ -1111,7 +1109,7 @@ void cmLocalGenerator::AddCompileOptions( { cmSystemTools::ParseWindowsCommandLine(targetFlags, opts); } - gtgt->GetCompileOptions(opts, config, lang); + target->GetCompileOptions(opts, config, lang); for(std::vector<std::string>::const_iterator i = opts.begin(); i != opts.end(); ++i) { @@ -1132,7 +1130,7 @@ void cmLocalGenerator::AddCompileOptions( this->AppendFlags(flags, targetFlags); } std::vector<std::string> opts; - gtgt->GetCompileOptions(opts, config, lang); + target->GetCompileOptions(opts, config, lang); for(std::vector<std::string>::const_iterator i = opts.begin(); i != opts.end(); ++i) { @@ -1141,11 +1139,11 @@ void cmLocalGenerator::AddCompileOptions( } } std::vector<std::string> features; - gtgt->GetCompileFeatures(features, config); + target->GetCompileFeatures(features, config); for(std::vector<std::string>::const_iterator it = features.begin(); it != features.end(); ++it) { - if (!this->Makefile->AddRequiredTargetFeature(target, *it)) + if (!this->Makefile->AddRequiredTargetFeature(target->Target, *it)) { return; } @@ -1180,7 +1178,7 @@ void cmLocalGenerator::AddCompileOptions( //---------------------------------------------------------------------------- void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, - cmGeneratorTarget* target, + cmGeneratorTarget const* target, const std::string& lang, const std::string& config, bool stripImplicitInclDirs @@ -1307,7 +1305,7 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, void cmLocalGenerator::GetStaticLibraryFlags(std::string& flags, std::string const& config, - cmTarget* target) + cmGeneratorTarget* target) { this->AppendFlags(flags, this->Makefile->GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS")); @@ -1340,12 +1338,12 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, switch(target->GetType()) { - case cmTarget::STATIC_LIBRARY: - this->GetStaticLibraryFlags(linkFlags, buildType, target->Target); + case cmState::STATIC_LIBRARY: + this->GetStaticLibraryFlags(linkFlags, buildType, target); break; - case cmTarget::MODULE_LIBRARY: + case cmState::MODULE_LIBRARY: libraryLinkVariable = "CMAKE_MODULE_LINKER_FLAGS"; - case cmTarget::SHARED_LIBRARY: + case cmState::SHARED_LIBRARY: { linkFlags = this->Makefile->GetSafeDefinition(libraryLinkVariable); linkFlags += " "; @@ -1397,7 +1395,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, *target, false, false, useWatcomQuote); } break; - case cmTarget::EXECUTABLE: + case cmState::EXECUTABLE: { linkFlags += this->Makefile->GetSafeDefinition("CMAKE_EXE_LINKER_FLAGS"); @@ -1414,7 +1412,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, { cmSystemTools::Error ("CMake can not determine linker language for target: ", - target->Target->GetName().c_str()); + target->GetName().c_str()); return; } this->AddLanguageFlags(flags, linkLanguage, buildType); @@ -1440,7 +1438,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, this->Makefile->GetSafeDefinition("CMAKE_CREATE_CONSOLE_EXE"); linkFlags += " "; } - if (target->Target->IsExecutableWithExports()) + if (target->IsExecutableWithExports()) { std::string exportFlagVar = "CMAKE_EXE_EXPORTS_"; exportFlagVar += linkLanguage; @@ -1542,12 +1540,12 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, this->Makefile->GetSafeDefinition("CMAKE_LIBRARY_PATH_TERMINATOR"); // Flags to link an executable to shared libraries. - if (tgt.GetType() == cmTarget::EXECUTABLE && + if (tgt.GetType() == cmState::EXECUTABLE && this->StateSnapshot.GetState()-> GetGlobalPropertyAsBool("TARGET_SUPPORTS_SHARED_LIBS")) { bool add_shlib_flags = false; - switch(tgt.Target->GetPolicyStatusCMP0065()) + switch(tgt.GetPolicyStatusCMP0065()) { case cmPolicies::WARN: if(!tgt.GetPropertyAsBool("ENABLE_EXPORTS") && @@ -1624,7 +1622,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, ItemVector const& items = cli.GetItems(); for(ItemVector::const_iterator li = items.begin(); li != items.end(); ++li) { - if(li->Target && li->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + if(li->Target && li->Target->GetType() == cmState::INTERFACE_LIBRARY) { continue; } @@ -1767,6 +1765,17 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, } //---------------------------------------------------------------------------- +cmGeneratorTarget* +cmLocalGenerator::FindGeneratorTargetToUse(const std::string& name) const +{ + if (cmTarget *t = this->Makefile->FindTargetToUse(name)) + { + return this->GetGlobalGenerator()->GetGeneratorTarget(t); + } + return 0; +} + +//---------------------------------------------------------------------------- bool cmLocalGenerator::GetRealDependency(const std::string& inName, const std::string& config, std::string& dep) @@ -1792,15 +1801,15 @@ bool cmLocalGenerator::GetRealDependency(const std::string& inName, // Look for a CMake target with the given name. if(cmGeneratorTarget* target = - this->Makefile->FindGeneratorTargetToUse(name)) + this->FindGeneratorTargetToUse(name)) { // make sure it is not just a coincidence that the target name // found is part of the inName if(cmSystemTools::FileIsFullPath(inName.c_str())) { std::string tLocation; - if(target->GetType() >= cmTarget::EXECUTABLE && - target->GetType() <= cmTarget::MODULE_LIBRARY) + if(target->GetType() >= cmState::EXECUTABLE && + target->GetType() <= cmState::MODULE_LIBRARY) { tLocation = target->GetLocation(config); tLocation = cmSystemTools::GetFilenamePath(tLocation); @@ -1820,23 +1829,23 @@ bool cmLocalGenerator::GetRealDependency(const std::string& inName, } switch (target->GetType()) { - case cmTarget::EXECUTABLE: - case cmTarget::STATIC_LIBRARY: - case cmTarget::SHARED_LIBRARY: - case cmTarget::MODULE_LIBRARY: - case cmTarget::UNKNOWN_LIBRARY: + case cmState::EXECUTABLE: + case cmState::STATIC_LIBRARY: + case cmState::SHARED_LIBRARY: + case cmState::MODULE_LIBRARY: + case cmState::UNKNOWN_LIBRARY: dep = target->GetLocation(config); return true; - case cmTarget::OBJECT_LIBRARY: + case cmState::OBJECT_LIBRARY: // An object library has no single file on which to depend. // This was listed to get the target-level dependency. return false; - case cmTarget::INTERFACE_LIBRARY: + case cmState::INTERFACE_LIBRARY: // An interface library has no file on which to depend. // This was listed to get the target-level dependency. return false; - case cmTarget::UTILITY: - case cmTarget::GLOBAL_TARGET: + case cmState::UTILITY: + case cmState::GLOBAL_TARGET: // A utility target has no file on which to depend. This was listed // only to get the target-level dependency. return false; @@ -1886,7 +1895,8 @@ void cmLocalGenerator::AddSharedFlags(std::string& flags, //---------------------------------------------------------------------------- void cmLocalGenerator:: -AddCompilerRequirementFlag(std::string &flags, cmTarget const* target, +AddCompilerRequirementFlag(std::string &flags, + cmGeneratorTarget const* target, const std::string& lang) { if (lang.empty()) @@ -1924,7 +1934,8 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget const* target, "CMAKE_" + lang + standardProp + "_" + type + "_COMPILE_OPTION"; - const char *opt = target->GetMakefile()->GetDefinition(option_flag); + const char *opt = target->Target->GetMakefile() + ->GetDefinition(option_flag); if (!opt) { std::ostringstream e; @@ -1989,7 +2000,7 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget const* target, + "_" + type + "_COMPILE_OPTION"; const char *opt = - target->GetMakefile()->GetRequiredDefinition(option_flag); + target->Target->GetMakefile()->GetRequiredDefinition(option_flag); this->AppendFlagEscape(flags, opt); return; } @@ -2000,7 +2011,8 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget const* target, "CMAKE_" + lang + *stdIt + "_" + type + "_COMPILE_OPTION"; - if (const char *opt = target->GetMakefile()->GetDefinition(option_flag)) + if (const char *opt = target->Target + ->GetMakefile()->GetDefinition(option_flag)) { this->AppendFlagEscape(flags, opt); return; @@ -2076,7 +2088,7 @@ static void AddInlineVisibilityCompileOption(std::string &flags, //---------------------------------------------------------------------------- void cmLocalGenerator -::AddVisibilityPresetFlags(std::string &flags, cmTarget const* target, +::AddVisibilityPresetFlags(std::string &flags, cmGeneratorTarget const* target, const std::string& lang) { if (lang.empty()) @@ -2086,8 +2098,8 @@ void cmLocalGenerator std::string warnCMP0063; std::string *pWarnCMP0063 = 0; - if (target->GetType() != cmTarget::SHARED_LIBRARY && - target->GetType() != cmTarget::MODULE_LIBRARY && + if (target->GetType() != cmState::SHARED_LIBRARY && + target->GetType() != cmState::MODULE_LIBRARY && !target->IsExecutableWithExports()) { switch (target->GetPolicyStatusCMP0063()) @@ -2102,11 +2114,12 @@ void cmLocalGenerator } } - AddVisibilityCompileOption(flags, target, this, lang, pWarnCMP0063); + AddVisibilityCompileOption(flags, target->Target, this, lang, pWarnCMP0063); if(lang == "CXX") { - AddInlineVisibilityCompileOption(flags, target, this, pWarnCMP0063); + AddInlineVisibilityCompileOption(flags, target->Target, + this, pWarnCMP0063); } if (!warnCMP0063.empty() && @@ -2116,25 +2129,26 @@ void cmLocalGenerator w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0063) << "\n" "Target \"" << target->GetName() << "\" of " - "type \"" << cmTarget::GetTargetTypeName(target->GetType()) << "\" " + "type \"" << cmState::GetTargetTypeName(target->GetType()) << "\" " "has the following visibility properties set for " << lang << ":\n" << warnCMP0063 << "For compatibility CMake is not honoring them for this target."; - target->GetMakefile()->GetCMakeInstance() - ->IssueMessage(cmake::AUTHOR_WARNING, w.str(), target->GetBacktrace()); + target->Target->GetMakefile()->GetCMakeInstance() + ->IssueMessage(cmake::AUTHOR_WARNING, w.str(), + target->GetBacktrace()); } } //---------------------------------------------------------------------------- void cmLocalGenerator::AddCMP0018Flags(std::string &flags, - cmTarget const* target, + cmGeneratorTarget const* target, std::string const& lang, const std::string& config) { int targetType = target->GetType(); - bool shared = ((targetType == cmTarget::SHARED_LIBRARY) || - (targetType == cmTarget::MODULE_LIBRARY)); + bool shared = ((targetType == cmState::SHARED_LIBRARY) || + (targetType == cmState::MODULE_LIBRARY)); if (this->GetShouldUseOldFlags(shared, lang)) { @@ -2142,7 +2156,7 @@ void cmLocalGenerator::AddCMP0018Flags(std::string &flags, } else { - if (target->GetType() == cmTarget::OBJECT_LIBRARY) + if (target->GetType() == cmState::OBJECT_LIBRARY) { if (target->GetPropertyAsBool("POSITION_INDEPENDENT_CODE")) { @@ -2151,9 +2165,7 @@ void cmLocalGenerator::AddCMP0018Flags(std::string &flags, return; } - cmGeneratorTarget* gtgt = - this->GlobalGenerator->GetGeneratorTarget(target); - if (gtgt->GetLinkInterfaceDependentBoolProperty( + if (target->GetLinkInterfaceDependentBoolProperty( "POSITION_INDEPENDENT_CODE", config)) { @@ -2216,7 +2228,7 @@ void cmLocalGenerator::AddPositionIndependentFlags(std::string& flags, { const char* picFlags = 0; - if(targetType == cmTarget::EXECUTABLE) + if(targetType == cmState::EXECUTABLE) { std::string flagsVar = "CMAKE_"; flagsVar += lang; @@ -2431,6 +2443,11 @@ const char* cmLocalGenerator::GetFeature(const std::string& feature, return 0; } +std::string cmLocalGenerator::GetProjectName() const +{ + return this->StateSnapshot.GetProjectName(); +} + //---------------------------------------------------------------------------- std::string cmLocalGenerator::ConstructComment(cmCustomCommandGenerator const& ccg, @@ -2489,7 +2506,7 @@ cmLocalGenerator cmTargets& tgts = this->Makefile->GetTargets(); for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); ++l) { - if (l->second.GetType() == cmTarget::INTERFACE_LIBRARY) + if (l->second.GetType() == cmState::INTERFACE_LIBRARY) { continue; } @@ -2517,9 +2534,9 @@ cmLocalGenerator // Generate the proper install generator for this target type. switch(l->second.GetType()) { - case cmTarget::EXECUTABLE: - case cmTarget::STATIC_LIBRARY: - case cmTarget::MODULE_LIBRARY: + case cmState::EXECUTABLE: + case cmState::STATIC_LIBRARY: + case cmState::MODULE_LIBRARY: { // Use a target install generator. cmInstallTargetGeneratorLocal @@ -2527,7 +2544,7 @@ cmLocalGenerator g.Generate(os, config, configurationTypes); } break; - case cmTarget::SHARED_LIBRARY: + case cmState::SHARED_LIBRARY: { #if defined(_WIN32) || defined(__CYGWIN__) // Special code to handle DLL. Install the import library @@ -2858,9 +2875,34 @@ cmLocalGenerator return source.GetLanguage(); } +cmake* cmLocalGenerator::GetCMakeInstance() const +{ + return this->GlobalGenerator->GetCMakeInstance(); +} + +const char* cmLocalGenerator::GetSourceDirectory() const +{ + return this->GetCMakeInstance()->GetHomeDirectory(); +} + +const char* cmLocalGenerator::GetBinaryDirectory() const +{ + return this->GetCMakeInstance()->GetHomeOutputDirectory(); +} + +const char* cmLocalGenerator::GetCurrentBinaryDirectory() const +{ + return this->StateSnapshot.GetDirectory().GetCurrentBinary(); +} + +const char* cmLocalGenerator::GetCurrentSourceDirectory() const +{ + return this->StateSnapshot.GetDirectory().GetCurrentSource(); +} + //---------------------------------------------------------------------------- std::string -cmLocalGenerator::GetTargetDirectory(cmTarget const&) const +cmLocalGenerator::GetTargetDirectory(const cmGeneratorTarget*) const { cmSystemTools::Error("GetTargetDirectory" " called on cmLocalGenerator"); @@ -2964,7 +3006,7 @@ bool cmLocalGenerator::CheckDefinition(std::string const& define) const } //---------------------------------------------------------------------------- -static void cmLGInfoProp(cmMakefile* mf, cmTarget* target, +static void cmLGInfoProp(cmMakefile* mf, cmGeneratorTarget* target, const std::string& prop) { if(const char* val = target->GetProperty(prop)) @@ -2974,7 +3016,7 @@ static void cmLGInfoProp(cmMakefile* mf, cmTarget* target, } //---------------------------------------------------------------------------- -void cmLocalGenerator::GenerateAppleInfoPList(cmTarget* target, +void cmLocalGenerator::GenerateAppleInfoPList(cmGeneratorTarget* target, const std::string& targetName, const char* fname) { @@ -3018,7 +3060,7 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmTarget* target, } //---------------------------------------------------------------------------- -void cmLocalGenerator::GenerateFrameworkInfoPList(cmTarget* target, +void cmLocalGenerator::GenerateFrameworkInfoPList(cmGeneratorTarget* target, const std::string& targetName, const char* fname) { |