diff options
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 28 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 51 | ||||
-rw-r--r-- | Source/cmLocalGenerator.h | 4 | ||||
-rw-r--r-- | Source/cmMakefileExecutableTargetGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmMakefileLibraryTargetGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 39 | ||||
-rw-r--r-- | Source/cmTarget.h | 3 |
8 files changed, 112 insertions, 25 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index d2c75b2..19d75d4 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1515,6 +1515,34 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, extraLinkOptions += targetLinkFlags; } + // Set target-specific architectures. + std::vector<std::string> archs; + target.GetAppleArchs(configName, archs); + if(!archs.empty()) + { + // Enable ARCHS attribute. + buildSettings->AddAttribute("ONLY_ACTIVE_ARCH", + this->CreateString("NO")); + + // Store ARCHS value. + if(archs.size() == 1) + { + buildSettings->AddAttribute("ARCHS", + this->CreateString(archs[0].c_str())); + } + else + { + cmXCodeObject* archObjects = + this->CreateObject(cmXCodeObject::OBJECT_LIST); + for(std::vector<std::string>::iterator i = archs.begin(); + i != archs.end(); i++) + { + archObjects->AddObject(this->CreateString((*i).c_str())); + } + buildSettings->AddAttribute("ARCHS", archObjects); + } + } + // Get the product name components. std::string pnprefix; std::string pnbase; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index c4ee5c7..5c86992 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -712,6 +712,9 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target) std::string langFlags; this->AddLanguageFlags(langFlags, llang, 0); +#ifdef __APPLE__ + this->AddArchitectureFlags(langFlags, &target, llang, 0); +#endif /* __APPLE__ */ vars.LanguageCompileFlags = langFlags.c_str(); cmCustomCommandLines commandLines; @@ -1751,21 +1754,18 @@ void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout, } } + //---------------------------------------------------------------------------- -void cmLocalGenerator::AddLanguageFlags(std::string& flags, - const char* lang, - const char* config) -{ - // Add language-specific flags. - std::string flagsVar = "CMAKE_"; - flagsVar += lang; - flagsVar += "_FLAGS"; - // Add special OSX flags #ifdef __APPLE__ +void cmLocalGenerator::AddArchitectureFlags(std::string& flags, + cmTarget* target, + const char *lang, + const char* config) +{ if(this->EmitUniversalBinaryFlags) { - const char* osxArch = - this->Makefile->GetDefinition("CMAKE_OSX_ARCHITECTURES"); + std::vector<std::string> archs; + target->GetAppleArchs(config, archs); const char* sysroot = this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT"); const char* sysrootDefault = @@ -1775,24 +1775,13 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, std::string isysrootVar = std::string("CMAKE_") + lang + "_HAS_ISYSROOT"; bool hasIsysroot = this->Makefile->IsOn(isysrootVar.c_str()); bool flagsUsed = false; - if(osxArch && sysroot && lang && (lang[0] =='C' || lang[0] == 'F')) + if(!archs.empty() && sysroot && lang && (lang[0] =='C' || lang[0] == 'F')) { - std::vector<std::string> archs; - cmSystemTools::ExpandListArgument(std::string(osxArch), - archs); - bool addArchFlag = false; - if(archs.size() >= 1) - { - if(archs[0] != "") - { - addArchFlag = true; - } - } // if there is more than one arch add the -arch and // -isysroot flags, or if there is one arch flag, but // it is not the default -arch flag for the system, then // add it. Otherwize do not add -arch and -isysroot - if(addArchFlag) + if(archs[0] != "") { for( std::vector<std::string>::iterator i = archs.begin(); i != archs.end(); ++i) @@ -1823,7 +1812,19 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, flags += deploymentTarget; } } -#endif +} +#endif /* __APPLE__ */ + + +//---------------------------------------------------------------------------- +void cmLocalGenerator::AddLanguageFlags(std::string& flags, + const char* lang, + const char* config) +{ + // Add language-specific flags. + std::string flagsVar = "CMAKE_"; + flagsVar += lang; + flagsVar += "_FLAGS"; this->AddConfigVariableFlags(flags, flagsVar.c_str(), config); } diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index d2082e4..029d315 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -133,6 +133,10 @@ public: std::vector<cmLocalGenerator*>& GetChildren() { return this->Children; }; +#ifdef __APPLE__ + void AddArchitectureFlags(std::string& flags, cmTarget* target, const char *lang, const char* config); +#endif /* __APPLE__ */ + void AddLanguageFlags(std::string& flags, const char* lang, const char* config); void AddSharedFlags(std::string& flags, const char* lang, bool shared); diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index a20c917..49b9d75 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -229,6 +229,10 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Add language feature flags. this->AddFeatureFlags(flags, linkLanguage); +#ifdef __APPLE__ + this->LocalGenerator->AddArchitectureFlags(flags, this->Target, linkLanguage, this->ConfigName); +#endif /* __APPLE__ */ + // Add target-specific linker flags. this->LocalGenerator->AppendFlags (linkFlags, this->Target->GetProperty("LINK_FLAGS")); diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 4070a3b..3cd9bfe 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -682,6 +682,10 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules std::string langFlags; this->AddFeatureFlags(langFlags, linkLanguage); +#ifdef __APPLE__ + this->LocalGenerator->AddArchitectureFlags(langFlags, this->Target, linkLanguage, this->ConfigName); +#endif /* __APPLE__ */ + // remove any language flags that might not work with the // particular os if(forbiddenFlagVar) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index c4f1d32..0a2e79e 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -294,6 +294,10 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags() // Add language feature flags. this->AddFeatureFlags(flags, lang); +#ifdef __APPLE__ + this->LocalGenerator->AddArchitectureFlags(flags, this->Target, lang, this->ConfigName); +#endif /* __APPLE__ */ + // Fortran-specific flags computed for this target. if(*l == "Fortran") { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index ccac68a..8b71505 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -573,6 +573,23 @@ void cmTarget::DefineProperties(cmake *cm) false /* TODO: make this chained */ ); cm->DefineProperty + ("OSX_ARCHITECTURES", cmProperty::TARGET, + "Target specific architectures for OS X.", + "The OSX_ARCHITECTURES property sets the target binary architecture " + "for targets on OS X. " + "This property is initialized by the value of the variable " + "CMAKE_OSX_ARCHITECTURES if it is set when a target is created. " + "Use OSX_ARCHITECTURES_<CONFIG> to set the binary architectures on a " + "per-configuration basis. " + "<CONFIG> is an upper-case name (ex: \"OSX_ARCHITECTURES_DEBUG\")."); + + cm->DefineProperty + ("OSX_ARCHITECTURES_<CONFIG>", cmProperty::TARGET, + "Per-configuration OS X binary architectures for a target.", + "This property is the configuration-specific version of " + "OSX_ARCHITECTURES."); + + cm->DefineProperty ("OUTPUT_NAME", cmProperty::TARGET, "Output name for target files.", "This sets the base name for output files created for an executable or " @@ -988,6 +1005,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->SetPropertyDefault("LIBRARY_OUTPUT_DIRECTORY", 0); this->SetPropertyDefault("RUNTIME_OUTPUT_DIRECTORY", 0); this->SetPropertyDefault("Fortran_MODULE_DIRECTORY", 0); + this->SetPropertyDefault("OSX_ARCHITECTURES", 0); // Collect the set of configuration types. std::vector<std::string> configNames; @@ -3653,6 +3671,27 @@ void cmTarget::GetLanguages(std::set<cmStdString>& languages) const } //---------------------------------------------------------------------------- +void cmTarget::GetAppleArchs(const char* config, + std::vector<std::string>& 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) { #if defined(CMAKE_USE_ELF_PARSER) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 66e3f3df..f2b7d61 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -410,6 +410,9 @@ public: // until we have per-target object file properties. void GetLanguages(std::set<cmStdString>& languages) const; + /** Get the list of OS X target architectures to be built. */ + void GetAppleArchs(const char* config, std::vector<std::string>& archVec); + /** Return whether this target is an executable with symbol exports enabled. */ bool IsExecutableWithExports(); |