diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index e53f35e39..96f0ee88d 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -315,3 +315,24 @@ cmGeneratorTarget::GetLinkInformation(const char* config) } return i->second; } + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetAppleArchs(const char* config, + std::vector& archVec) +{ + const char* archs = 0; + if(config && *config) + { + std::string defVarName = "OSX_ARCHITECTURES_"; + defVarName += cmSystemTools::UpperCase(config); + archs = this->Target->GetProperty(defVarName.c_str()); + } + if(!archs) + { + archs = this->Target->GetProperty("OSX_ARCHITECTURES"); + } + if(archs) + { + cmSystemTools::ExpandListArgument(std::string(archs), archVec); + } +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index fefdfb1a5..ad1aa6234 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -67,6 +67,8 @@ public: cmComputeLinkInformation* GetLinkInformation(const char* config); + void GetAppleArchs(const char* config, + std::vector& archVec); private: void ClassifySources(); void LookupObjectLibraries(); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 5ac9070cf..599acd522 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1713,7 +1713,10 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // Set target-specific architectures. std::vector archs; - target.GetAppleArchs(configName, archs); + { + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); + gtgt->GetAppleArchs(configName, archs); + } if(!archs.empty()) { // Enable ARCHS attribute. diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 24d9b91d7..62b0f5e85 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -555,9 +555,9 @@ void cmLocalGenerator::GenerateTargetManifest() } void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, - const char* lang, - cmSourceFile& source, - cmTarget& target) + const char* lang, + cmSourceFile& source, + cmGeneratorTarget& target) { std::string objectDir = cmSystemTools::GetFilenamePath(std::string(ofname)); objectDir = this->Convert(objectDir.c_str(),START_OUTPUT,SHELL); @@ -577,7 +577,7 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, flags += " "; { std::vector includes; - this->GetIncludeDirectories(includes, &target, lang); + this->GetIncludeDirectories(includes, target.Target, lang); flags += this->GetIncludeFlags(includes, lang); } flags += this->Makefile->GetDefineFlags(); @@ -636,7 +636,8 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, ); } -void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target) +void cmLocalGenerator::AddBuildTargetRule(const char* llang, + cmGeneratorTarget& target) { cmStdString objs; std::vector objVector; @@ -669,8 +670,8 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target) } std::string createRule = "CMAKE_"; createRule += llang; - createRule += target.GetCreateRuleVariable(); - std::string targetName = target.GetFullName(); + createRule += target.Target->GetCreateRuleVariable(); + std::string targetName = target.Target->GetFullName(); // Executable : // Shared Library: // Static Library: @@ -678,7 +679,7 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target) std::string linkLibs; // should be set std::string flags; // should be set std::string linkFlags; // should be set - this->GetTargetFlags(linkLibs, flags, linkFlags, target); + this->GetTargetFlags(linkLibs, flags, linkFlags, *target.Target); cmLocalGenerator::RuleVariables vars; vars.Language = llang; vars.Objects = objs.c_str(); @@ -715,7 +716,7 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target) // Store this command line. commandLines.push_back(commandLine); } - std::string targetFullPath = target.GetFullPath(); + std::string targetFullPath = target.Target->GetFullPath(); // Generate a meaningful comment for the command. std::string comment = "Linking "; comment += llang; @@ -729,7 +730,7 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target) comment.c_str(), this->Makefile->GetStartOutputDirectory() ); - target.AddSourceFile + target.Target->AddSourceFile (this->Makefile->GetSource(targetFullPath.c_str())); } @@ -737,11 +738,11 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target) void cmLocalGenerator ::CreateCustomTargetsAndCommands(std::set const& lang) { - cmTargets &tgts = this->Makefile->GetTargets(); - for(cmTargets::iterator l = tgts.begin(); + cmGeneratorTargetsType tgts = this->Makefile->GetGeneratorTargets(); + for(cmGeneratorTargetsType::iterator l = tgts.begin(); l != tgts.end(); l++) { - cmTarget& target = l->second; + cmGeneratorTarget& target = *l->second; switch(target.GetType()) { case cmTarget::STATIC_LIBRARY: @@ -749,12 +750,12 @@ void cmLocalGenerator case cmTarget::MODULE_LIBRARY: case cmTarget::EXECUTABLE: { - const char* llang = target.GetLinkerLanguage(); + const char* llang = target.Target->GetLinkerLanguage(); if(!llang) { cmSystemTools::Error ("CMake can not determine linker language for target:", - target.GetName()); + target.Target->GetName()); return; } // if the language is not in the set lang then create custom @@ -1780,7 +1781,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout, //---------------------------------------------------------------------------- void cmLocalGenerator::AddArchitectureFlags(std::string& flags, - cmTarget* target, + cmGeneratorTarget* target, const char *lang, const char* config) { diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index b3396e3a5..e371e40cc 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -16,6 +16,7 @@ class cmMakefile; class cmGlobalGenerator; +class cmGeneratorTarget; class cmTarget; class cmTargetManifest; class cmSourceFile; @@ -135,7 +136,7 @@ public: std::vector& GetChildren() { return this->Children; }; - void AddArchitectureFlags(std::string& flags, cmTarget* target, + void AddArchitectureFlags(std::string& flags, cmGeneratorTarget* target, const char *lang, const char* config); void AddLanguageFlags(std::string& flags, const char* lang, @@ -354,12 +355,12 @@ protected: /** Convert a target to a utility target for unsupported * languages of a generator */ - void AddBuildTargetRule(const char* llang, cmTarget& target); + void AddBuildTargetRule(const char* llang, cmGeneratorTarget& target); ///! add a custom command to build a .o file that is part of a target void AddCustomCommandToCreateObject(const char* ofname, const char* lang, cmSourceFile& source, - cmTarget& target); + cmGeneratorTarget& target); // Create Custom Targets and commands for unsupported languages // The set passed in should contain the languages supported by the // generator directly. Any targets containing files that are not diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index ab5150a36..d1c5b6261 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -210,7 +210,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Add language feature flags. this->AddFeatureFlags(flags, linkLanguage); - this->LocalGenerator->AddArchitectureFlags(flags, this->Target, + this->LocalGenerator->AddArchitectureFlags(flags, this->GeneratorTarget, linkLanguage, this->ConfigName); // Add target-specific linker flags. diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 577e5fd07..cc7d9c745 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -625,7 +625,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules std::string langFlags; this->AddFeatureFlags(langFlags, linkLanguage); - this->LocalGenerator->AddArchitectureFlags(langFlags, this->Target, + this->LocalGenerator->AddArchitectureFlags(langFlags, this->GeneratorTarget, linkLanguage, this->ConfigName); // remove any language flags that might not work with the diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index c818b7ef1..51ba75dd1 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -259,7 +259,7 @@ std::string cmMakefileTargetGenerator::GetFlags(const std::string &l) // Add language feature flags. this->AddFeatureFlags(flags, lang); - this->LocalGenerator->AddArchitectureFlags(flags, this->Target, + this->LocalGenerator->AddArchitectureFlags(flags, this->GeneratorTarget, lang, this->ConfigName); // Fortran-specific flags computed for this target. diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 9dc860ee9..082e9f37e 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -434,7 +434,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() ? vars["FLAGS"] : vars["ARCH_FLAGS"]); this->GetLocalGenerator()->AddArchitectureFlags(flags, - this->GetTarget(), + this->GetGeneratorTarget(), this->TargetLinkLanguage, this->GetConfigName()); if (targetType == cmTarget::EXECUTABLE) { diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index b301d1bdd..909d98011 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -134,7 +134,7 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source, this->AddFeatureFlags(flags, language.c_str()); this->GetLocalGenerator()->AddArchitectureFlags(flags, - this->GetTarget(), + this->GeneratorTarget, language.c_str(), this->GetConfigName()); diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index cd20694b4..cf06bfdf5 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -52,6 +52,9 @@ protected: cmTarget* GetTarget() const { return this->Target; } + cmGeneratorTarget* GetGeneratorTarget() const + { return this->GeneratorTarget; } + cmLocalNinjaGenerator* GetLocalGenerator() const { return this->LocalGenerator; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index cce5cd6fb..c556813ca 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3908,27 +3908,6 @@ void cmTarget::GetLanguages(std::set& languages) const } } -//---------------------------------------------------------------------------- -void cmTarget::GetAppleArchs(const char* config, - std::vector& archVec) -{ - const char* archs = 0; - if(config && *config) - { - std::string defVarName = "OSX_ARCHITECTURES_"; - defVarName += cmSystemTools::UpperCase(config); - archs = this->GetProperty(defVarName.c_str()); - } - if(!archs) - { - archs = this->GetProperty("OSX_ARCHITECTURES"); - } - if(archs) - { - cmSystemTools::ExpandListArgument(std::string(archs), archVec); - } -} - //---------------------------------------------------------------------------- bool cmTarget::IsChrpathUsed(const char* config) { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 9493b68cf..f5ef72c2f 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -404,9 +404,6 @@ public: // until we have per-target object file properties. void GetLanguages(std::set& languages) const; - /** Get the list of OS X target architectures to be built. */ - void GetAppleArchs(const char* config, std::vector& archVec); - /** Return whether this target is an executable with symbol exports enabled. */ bool IsExecutableWithExports();