فهرست منبع

cmMakefile: Create an explicit "Object Libraries" source group

The generators should not need special logic to place object library
object files in this group.
Brad King 8 سال پیش
والد
کامیت
22829a1304
3فایلهای تغییر یافته به همراه25 افزوده شده و 5 حذف شده
  1. 5 5
      Source/cmGeneratorExpressionNode.cxx
  2. 16 0
      Source/cmMakefile.cxx
  3. 4 0
      Source/cmMakefile.h

+ 5 - 5
Source/cmGeneratorExpressionNode.cxx

@@ -14,7 +14,6 @@
 #include "cmMakefile.h"
 #include "cmMakefile.h"
 #include "cmOutputConverter.h"
 #include "cmOutputConverter.h"
 #include "cmPolicies.h"
 #include "cmPolicies.h"
-#include "cmSourceFile.h"
 #include "cmStateTypes.h"
 #include "cmStateTypes.h"
 #include "cmSystemTools.h"
 #include "cmSystemTools.h"
 #include "cmTarget.h"
 #include "cmTarget.h"
@@ -34,6 +33,8 @@
 #include <string.h>
 #include <string.h>
 #include <utility>
 #include <utility>
 
 
+class cmSourceFile;
+
 std::string cmGeneratorExpressionNode::EvaluateDependentExpression(
 std::string cmGeneratorExpressionNode::EvaluateDependentExpression(
   std::string const& prop, cmLocalGenerator* lg,
   std::string const& prop, cmLocalGenerator* lg,
   cmGeneratorExpressionContext* context, cmGeneratorTarget const* headTarget,
   cmGeneratorExpressionContext* context, cmGeneratorTarget const* headTarget,
@@ -1265,6 +1266,8 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode
 
 
     gt->LocalGenerator->ComputeObjectFilenames(mapping, gt);
     gt->LocalGenerator->ComputeObjectFilenames(mapping, gt);
 
 
+    cmMakefile* mf = context->LG->GetMakefile();
+
     std::string obj_dir = gt->ObjectDirectory;
     std::string obj_dir = gt->ObjectDirectory;
     std::string result;
     std::string result;
     const char* sep = "";
     const char* sep = "";
@@ -1278,10 +1281,7 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode
       assert(!map_it->second.empty());
       assert(!map_it->second.empty());
       result += sep;
       result += sep;
       std::string objFile = obj_dir + map_it->second;
       std::string objFile = obj_dir + map_it->second;
-      cmSourceFile* sf =
-        context->LG->GetMakefile()->GetOrCreateSource(objFile, true);
-      sf->SetObjectLibrary(tgtName);
-      sf->SetProperty("EXTERNAL_OBJECT", "1");
+      mf->AddTargetObject(tgtName, objFile);
       result += objFile;
       result += objFile;
       sep = ";";
       sep = ";";
     }
     }

+ 16 - 0
Source/cmMakefile.cxx

@@ -94,6 +94,10 @@ cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator,
   this->AddSourceGroup("CMake Rules", "\\.rule$");
   this->AddSourceGroup("CMake Rules", "\\.rule$");
   this->AddSourceGroup("Resources", "\\.plist$");
   this->AddSourceGroup("Resources", "\\.plist$");
   this->AddSourceGroup("Object Files", "\\.(lo|o|obj)$");
   this->AddSourceGroup("Object Files", "\\.(lo|o|obj)$");
+
+  this->ObjectLibrariesSourceGroupIndex = this->SourceGroups.size();
+  this->SourceGroups.push_back(
+    cmSourceGroup("Object Libraries", "^MATCH_NO_SOURCES$"));
 #endif
 #endif
 }
 }
 
 
@@ -3124,6 +3128,18 @@ cmSourceFile* cmMakefile::GetOrCreateSource(const std::string& sourceName,
   return this->CreateSource(sourceName, generated);
   return this->CreateSource(sourceName, generated);
 }
 }
 
 
+void cmMakefile::AddTargetObject(std::string const& tgtName,
+                                 std::string const& objFile)
+{
+  cmSourceFile* sf = this->GetOrCreateSource(objFile, true);
+  sf->SetObjectLibrary(tgtName);
+  sf->SetProperty("EXTERNAL_OBJECT", "1");
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+  this->SourceGroups[this->ObjectLibrariesSourceGroupIndex].AddGroupFile(
+    sf->GetFullPath());
+#endif
+}
+
 void cmMakefile::EnableLanguage(std::vector<std::string> const& lang,
 void cmMakefile::EnableLanguage(std::vector<std::string> const& lang,
                                 bool optional)
                                 bool optional)
 {
 {

+ 4 - 0
Source/cmMakefile.h

@@ -9,6 +9,7 @@
 #include <map>
 #include <map>
 #include <set>
 #include <set>
 #include <stack>
 #include <stack>
+#include <stddef.h>
 #include <string>
 #include <string>
 #include <vector>
 #include <vector>
 
 
@@ -406,6 +407,8 @@ public:
   cmSourceFile* GetOrCreateSource(const std::string& sourceName,
   cmSourceFile* GetOrCreateSource(const std::string& sourceName,
                                   bool generated = false);
                                   bool generated = false);
 
 
+  void AddTargetObject(std::string const& tgtName, std::string const& objFile);
+
   /**
   /**
    * Given a variable name, return its value (as a string).
    * Given a variable name, return its value (as a string).
    * If the variable is not found in this makefile instance, the
    * If the variable is not found in this makefile instance, the
@@ -817,6 +820,7 @@ protected:
 
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
 #if defined(CMAKE_BUILD_WITH_CMAKE)
   std::vector<cmSourceGroup> SourceGroups;
   std::vector<cmSourceGroup> SourceGroups;
+  size_t ObjectLibrariesSourceGroupIndex;
 #endif
 #endif
 
 
   std::vector<cmCommand*> FinalPassCommands;
   std::vector<cmCommand*> FinalPassCommands;