Browse Source

Xcode: Honor $<TARGET_OBJECTS:...> source expressions

Add objects from object libraries referenced using this syntax to the
set of objects linked in a target.
David Cole 13 years ago
parent
commit
63d1be8b00
1 changed files with 33 additions and 0 deletions
  1. 33 0
      Source/cmGlobalXCodeGenerator.cxx

+ 33 - 0
Source/cmGlobalXCodeGenerator.cxx

@@ -295,6 +295,10 @@ void cmGlobalXCodeGenerator::Generate()
     }
     }
   this->ForceLinkerLanguages();
   this->ForceLinkerLanguages();
   this->cmGlobalGenerator::Generate();
   this->cmGlobalGenerator::Generate();
+  if(cmSystemTools::GetErrorOccuredFlag())
+    {
+    return;
+    }
   for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it)
   for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it)
     {
     {
     cmLocalGenerator* root = it->second[0];
     cmLocalGenerator* root = it->second[0];
@@ -945,6 +949,20 @@ 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);
+      }
+
     // some build phases only apply to bundles and/or frameworks
     // some build phases only apply to bundles and/or frameworks
     bool isFrameworkTarget = cmtarget.IsFrameworkOnApple();
     bool isFrameworkTarget = cmtarget.IsFrameworkOnApple();
     bool isBundleTarget = cmtarget.GetPropertyAsBool("MACOSX_BUNDLE");
     bool isBundleTarget = cmtarget.GetPropertyAsBool("MACOSX_BUNDLE");
@@ -2719,6 +2737,21 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root,
         cmStdString key = GetGroupMapKey(cmtarget, sf);
         cmStdString key = GetGroupMapKey(cmtarget, sf);
         this->GroupMap[key] = pbxgroup;
         this->GroupMap[key] = pbxgroup;
         }
         }
+
+      // Put OBJECT_LIBRARY objects in proper groups:
+      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 const& source = *oi;
+        cmSourceGroup& sourceGroup =
+          mf->FindSourceGroup(source.c_str(), sourceGroups);
+        cmXCodeObject* pbxgroup =
+          this->CreateOrGetPBXGroup(cmtarget, &sourceGroup);
+        cmStdString key = GetGroupMapKeyFromPath(cmtarget, source);
+        this->GroupMap[key] = pbxgroup;
+        }
       }
       }
     }
     }
 }
 }