summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalXCodeGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2013-10-02 15:52:18 (GMT)
committerBrad King <brad.king@kitware.com>2013-10-02 17:03:21 (GMT)
commita3194ff4a70c60db4fcf7d0d9bee2139af67ec8f (patch)
tree85cac4fa31ee4f26d99e11b23eba830a6ca9660c /Source/cmGlobalXCodeGenerator.cxx
parentdff8d113b4e7009436072af1b458272492badee6 (diff)
downloadCMake-a3194ff4a70c60db4fcf7d0d9bee2139af67ec8f.zip
CMake-a3194ff4a70c60db4fcf7d0d9bee2139af67ec8f.tar.gz
CMake-a3194ff4a70c60db4fcf7d0d9bee2139af67ec8f.tar.bz2
Xcode: Fix OBJECT library support for Xcode 5 (#14254)
Xcode 2.1 through 4 supported $(CURRENT_ARCH) in a PBXFileReference 'path' value used in the "Link Binary with Libraries" build phase. CMake uses this to reference object file locations on link lines to bring in OBJECT library content. However, Xcode 5 now evaluates the $(CURRENT_ARCH) reference in this context as "undefined_arch" so the wrong path is given to the linker. There seems to be no alternative way to produce an architecture-specific value in a PBXFileReference. Fortunately Xcode 5 now also handles link dependencies for paths linked through OTHER_LDFLAGS. For Xcode >= 5, move the OBJECT library object file references from the link build phase to OTHER_LDFLAGS. We can still show the object files in the source group listing in either case.
Diffstat (limited to 'Source/cmGlobalXCodeGenerator.cxx')
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx59
1 files changed, 40 insertions, 19 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 002c219..0a2b32b 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -1031,18 +1031,21 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
}
}
- // Add object library contents as external objects. (Equivalent to
- // the externalObjFiles above, except each one is not a cmSourceFile
- // within the target.)
- std::vector<std::string> objs;
- this->GetGeneratorTarget(&cmtarget)->UseObjectLibraries(objs);
- for(std::vector<std::string>::const_iterator
- oi = objs.begin(); oi != objs.end(); ++oi)
- {
- std::string obj = *oi;
- cmXCodeObject* xsf =
- this->CreateXCodeSourceFileFromPath(obj, cmtarget, "");
- externalObjFiles.push_back(xsf);
+ if(this->XcodeVersion < 50)
+ {
+ // Add object library contents as external objects. (Equivalent to
+ // the externalObjFiles above, except each one is not a cmSourceFile
+ // within the target.)
+ std::vector<std::string> objs;
+ this->GetGeneratorTarget(&cmtarget)->UseObjectLibraries(objs);
+ for(std::vector<std::string>::const_iterator
+ oi = objs.begin(); oi != objs.end(); ++oi)
+ {
+ std::string obj = *oi;
+ cmXCodeObject* xsf =
+ this->CreateXCodeSourceFileFromPath(obj, cmtarget, "");
+ externalObjFiles.push_back(xsf);
+ }
}
// some build phases only apply to bundles and/or frameworks
@@ -2769,13 +2772,6 @@ void cmGlobalXCodeGenerator
}
}
- // Skip link information for static libraries.
- if(cmtarget->GetType() == cmTarget::OBJECT_LIBRARY ||
- cmtarget->GetType() == cmTarget::STATIC_LIBRARY)
- {
- return;
- }
-
// Loop over configuration types and set per-configuration info.
for(std::vector<std::string>::iterator i =
this->CurrentConfigurationTypes.begin();
@@ -2788,6 +2784,31 @@ void cmGlobalXCodeGenerator
configName = 0;
}
+ if(this->XcodeVersion >= 50)
+ {
+ // Add object library contents as link flags.
+ std::string linkObjs;
+ const char* sep = "";
+ std::vector<std::string> objs;
+ this->GetGeneratorTarget(cmtarget)->UseObjectLibraries(objs);
+ for(std::vector<std::string>::const_iterator
+ oi = objs.begin(); oi != objs.end(); ++oi)
+ {
+ linkObjs += sep;
+ sep = " ";
+ linkObjs += this->XCodeEscapePath(oi->c_str());
+ }
+ this->AppendBuildSettingAttribute(target, "OTHER_LDFLAGS",
+ linkObjs.c_str(), configName);
+ }
+
+ // Skip link information for object libraries.
+ if(cmtarget->GetType() == cmTarget::OBJECT_LIBRARY ||
+ cmtarget->GetType() == cmTarget::STATIC_LIBRARY)
+ {
+ continue;
+ }
+
// Compute the link library and directory information.
cmComputeLinkInformation* pcli = cmtarget->GetLinkInformation(configName);
if(!pcli)