[Cmake-commits] [cmake-commits] king committed cmGlobalXCodeGenerator.cxx 1.234 1.235 cmLocalGenerator.cxx 1.320 1.321 cmLocalGenerator.h 1.119 1.120 cmMakefileExecutableTargetGenerator.cxx 1.66 1.67 cmMakefileLibraryTargetGenerator.cxx 1.82 1.83 cmMakefileTargetGenerator.cxx 1.129 1.130 cmTarget.cxx 1.281 1.282 cmTarget.h 1.148 1.149
cmake-commits at cmake.org
cmake-commits at cmake.org
Wed Oct 21 13:00:51 EDT 2009
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv2181/Source
Modified Files:
cmGlobalXCodeGenerator.cxx cmLocalGenerator.cxx
cmLocalGenerator.h cmMakefileExecutableTargetGenerator.cxx
cmMakefileLibraryTargetGenerator.cxx
cmMakefileTargetGenerator.cxx cmTarget.cxx cmTarget.h
Log Message:
Define per-target OSX_ARCHITECTURES property
The CMAKE_OSX_ARCHITECTURES variable works only as a global setting.
This commit defines target properties
OSX_ARCHITECTURES
OSX_ARCHITECTURES_<CONFIG>
to specify OS X architectures on a per-target and per-configuration
basis. See issue #8725.
Index: cmLocalGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalGenerator.cxx,v
retrieving revision 1.320
retrieving revision 1.321
diff -C 2 -d -r1.320 -r1.321
*** cmLocalGenerator.cxx 8 Oct 2009 15:55:58 -0000 1.320
--- cmLocalGenerator.cxx 21 Oct 2009 17:00:47 -0000 1.321
***************
*** 713,716 ****
--- 713,719 ----
std::string langFlags;
this->AddLanguageFlags(langFlags, llang, 0);
+ #ifdef __APPLE__
+ this->AddArchitectureFlags(langFlags, &target, llang, 0);
+ #endif /* __APPLE__ */
vars.LanguageCompileFlags = langFlags.c_str();
***************
*** 1752,1770 ****
}
//----------------------------------------------------------------------------
- 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__
if(this->EmitUniversalBinaryFlags)
{
! const char* osxArch =
! this->Makefile->GetDefinition("CMAKE_OSX_ARCHITECTURES");
const char* sysroot =
this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT");
--- 1755,1770 ----
}
+
//----------------------------------------------------------------------------
#ifdef __APPLE__
+ void cmLocalGenerator::AddArchitectureFlags(std::string& flags,
+ cmTarget* target,
+ const char *lang,
+ const char* config)
+ {
if(this->EmitUniversalBinaryFlags)
{
! std::vector<std::string> archs;
! target->GetAppleArchs(config, archs);
const char* sysroot =
this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT");
***************
*** 1776,1797 ****
bool hasIsysroot = this->Makefile->IsOn(isysrootVar.c_str());
bool flagsUsed = false;
! if(osxArch && 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)
{
for( std::vector<std::string>::iterator i = archs.begin();
--- 1776,1786 ----
bool hasIsysroot = this->Makefile->IsOn(isysrootVar.c_str());
bool flagsUsed = false;
! if(!archs.empty() && sysroot && lang && (lang[0] =='C' || lang[0] == 'F'))
{
// 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(archs[0] != "")
{
for( std::vector<std::string>::iterator i = archs.begin();
***************
*** 1824,1828 ****
}
}
! #endif
this->AddConfigVariableFlags(flags, flagsVar.c_str(), config);
}
--- 1813,1829 ----
}
}
! }
! #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);
}
Index: cmLocalGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalGenerator.h,v
retrieving revision 1.119
retrieving revision 1.120
diff -C 2 -d -r1.119 -r1.120
*** cmLocalGenerator.h 2 Oct 2009 17:52:00 -0000 1.119
--- cmLocalGenerator.h 21 Oct 2009 17:00:47 -0000 1.120
***************
*** 134,137 ****
--- 134,141 ----
+ #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);
Index: cmGlobalXCodeGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalXCodeGenerator.cxx,v
retrieving revision 1.234
retrieving revision 1.235
diff -C 2 -d -r1.234 -r1.235
*** cmGlobalXCodeGenerator.cxx 7 Oct 2009 12:15:14 -0000 1.234
--- cmGlobalXCodeGenerator.cxx 21 Oct 2009 17:00:38 -0000 1.235
***************
*** 1516,1519 ****
--- 1516,1547 ----
}
+ // 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;
Index: cmMakefileLibraryTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileLibraryTargetGenerator.cxx,v
retrieving revision 1.82
retrieving revision 1.83
diff -C 2 -d -r1.82 -r1.83
*** cmMakefileLibraryTargetGenerator.cxx 2 Oct 2009 17:52:13 -0000 1.82
--- cmMakefileLibraryTargetGenerator.cxx 21 Oct 2009 17:00:47 -0000 1.83
***************
*** 683,686 ****
--- 683,690 ----
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
Index: cmTarget.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.h,v
retrieving revision 1.148
retrieving revision 1.149
diff -C 2 -d -r1.148 -r1.149
*** cmTarget.h 5 Oct 2009 13:06:59 -0000 1.148
--- cmTarget.h 21 Oct 2009 17:00:49 -0000 1.149
***************
*** 411,414 ****
--- 411,417 ----
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. */
Index: cmMakefileExecutableTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileExecutableTargetGenerator.cxx,v
retrieving revision 1.66
retrieving revision 1.67
diff -C 2 -d -r1.66 -r1.67
*** cmMakefileExecutableTargetGenerator.cxx 8 Oct 2009 15:56:30 -0000 1.66
--- cmMakefileExecutableTargetGenerator.cxx 21 Oct 2009 17:00:47 -0000 1.67
***************
*** 230,233 ****
--- 230,237 ----
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
Index: cmMakefileTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileTargetGenerator.cxx,v
retrieving revision 1.129
retrieving revision 1.130
diff -C 2 -d -r1.129 -r1.130
*** cmMakefileTargetGenerator.cxx 3 Oct 2009 12:35:53 -0000 1.129
--- cmMakefileTargetGenerator.cxx 21 Oct 2009 17:00:48 -0000 1.130
***************
*** 295,298 ****
--- 295,302 ----
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")
Index: cmTarget.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.cxx,v
retrieving revision 1.281
retrieving revision 1.282
diff -C 2 -d -r1.281 -r1.282
*** cmTarget.cxx 6 Oct 2009 13:59:05 -0000 1.281
--- cmTarget.cxx 21 Oct 2009 17:00:49 -0000 1.282
***************
*** 574,577 ****
--- 574,594 ----
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.",
***************
*** 989,992 ****
--- 1006,1010 ----
this->SetPropertyDefault("RUNTIME_OUTPUT_DIRECTORY", 0);
this->SetPropertyDefault("Fortran_MODULE_DIRECTORY", 0);
+ this->SetPropertyDefault("OSX_ARCHITECTURES", 0);
// Collect the set of configuration types.
***************
*** 3654,3657 ****
--- 3672,3696 ----
//----------------------------------------------------------------------------
+ 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)
{
More information about the Cmake-commits
mailing list