Browse Source

Merge topic 'object-library-link-entries'

2c7acd34e2 cmComputeLinkInformation: add `OBJECT` libraries as link items
e166bbef7b cmComputeLinkInformation: prepare Item consumers for `OBJECT` libraries

Acked-by: Kitware Robot <[email protected]>
Tested-by: buildbot <[email protected]>
Merge-request: !8651
Brad King 2 years ago
parent
commit
735c305ba7

+ 1 - 7
Source/cmCommonTargetGenerator.cxx

@@ -173,13 +173,7 @@ std::vector<std::string> cmCommonTargetGenerator::GetLinkedTargetDirectories(
         this->GeneratorTarget->GetLinkInformation(config)) {
         this->GeneratorTarget->GetLinkInformation(config)) {
     std::vector<cmGeneratorTarget const*> targets;
     std::vector<cmGeneratorTarget const*> targets;
     for (auto const& item : cli->GetItems()) {
     for (auto const& item : cli->GetItems()) {
-      targets.push_back(item.Target);
-    }
-    for (auto const* target : cli->GetObjectLibrariesLinked()) {
-      targets.push_back(target);
-    }
-
-    for (auto const* linkee : targets) {
+      auto const* linkee = item.Target;
       if (linkee &&
       if (linkee &&
           !linkee->IsImported()
           !linkee->IsImported()
           // Skip targets that build after this one in a static lib cycle.
           // Skip targets that build after this one in a static lib cycle.

+ 1 - 12
Source/cmComputeLinkInformation.cxx

@@ -536,12 +536,6 @@ cmComputeLinkInformation::GetSharedLibrariesLinked() const
   return this->SharedLibrariesLinked;
   return this->SharedLibrariesLinked;
 }
 }
 
 
-const std::vector<const cmGeneratorTarget*>&
-cmComputeLinkInformation::GetObjectLibrariesLinked() const
-{
-  return this->ObjectLibrariesLinked;
-}
-
 bool cmComputeLinkInformation::Compute()
 bool cmComputeLinkInformation::Compute()
 {
 {
   // Skip targets that do not link.
   // Skip targets that do not link.
@@ -1164,12 +1158,7 @@ void cmComputeLinkInformation::AddItem(LinkEntry const& entry)
         this->AddItem(BT<std::string>(libName, item.Backtrace));
         this->AddItem(BT<std::string>(libName, item.Backtrace));
       }
       }
     } else if (tgt->GetType() == cmStateEnums::OBJECT_LIBRARY) {
     } else if (tgt->GetType() == cmStateEnums::OBJECT_LIBRARY) {
-      if (!tgt->HaveCxx20ModuleSources() && !tgt->HaveFortranSources(config)) {
-        // Ignore object library!
-        // Its object-files should already have been extracted for linking.
-      } else {
-        this->ObjectLibrariesLinked.push_back(entry.Target);
-      }
+      this->Items.emplace_back(entry.Item, ItemIsPath::No, entry.Target);
     } else if (this->GlobalGenerator->IsXcode() &&
     } else if (this->GlobalGenerator->IsXcode() &&
                !tgt->GetImportedXcFrameworkPath(config).empty()) {
                !tgt->GetImportedXcFrameworkPath(config).empty()) {
       this->Items.emplace_back(
       this->Items.emplace_back(

+ 0 - 3
Source/cmComputeLinkInformation.h

@@ -97,8 +97,6 @@ public:
   std::string GetRPathString(bool for_install) const;
   std::string GetRPathString(bool for_install) const;
   std::string GetChrpathString() const;
   std::string GetChrpathString() const;
   std::set<cmGeneratorTarget const*> const& GetSharedLibrariesLinked() const;
   std::set<cmGeneratorTarget const*> const& GetSharedLibrariesLinked() const;
-  std::vector<cmGeneratorTarget const*> const& GetObjectLibrariesLinked()
-    const;
   std::vector<cmGeneratorTarget const*> const& GetRuntimeDLLs() const
   std::vector<cmGeneratorTarget const*> const& GetRuntimeDLLs() const
   {
   {
     return this->RuntimeDLLs;
     return this->RuntimeDLLs;
@@ -136,7 +134,6 @@ private:
   std::vector<std::string> XcFrameworkHeaderPaths;
   std::vector<std::string> XcFrameworkHeaderPaths;
   std::vector<std::string> RuntimeSearchPath;
   std::vector<std::string> RuntimeSearchPath;
   std::set<cmGeneratorTarget const*> SharedLibrariesLinked;
   std::set<cmGeneratorTarget const*> SharedLibrariesLinked;
-  std::vector<cmGeneratorTarget const*> ObjectLibrariesLinked;
   std::vector<cmGeneratorTarget const*> RuntimeDLLs;
   std::vector<cmGeneratorTarget const*> RuntimeDLLs;
 
 
   // Context information.
   // Context information.

+ 1 - 1
Source/cmExportFileGenerator.cxx

@@ -536,7 +536,7 @@ static void getCompatibleInterfaceProperties(
   const cmComputeLinkInformation::ItemVector& deps = info->GetItems();
   const cmComputeLinkInformation::ItemVector& deps = info->GetItems();
 
 
   for (auto const& dep : deps) {
   for (auto const& dep : deps) {
-    if (!dep.Target) {
+    if (!dep.Target || dep.Target->GetType() == cmStateEnums::OBJECT_LIBRARY) {
       continue;
       continue;
     }
     }
     getPropertyContents(dep.Target, "COMPATIBLE_INTERFACE_BOOL",
     getPropertyContents(dep.Target, "COMPATIBLE_INTERFACE_BOOL",

+ 1 - 1
Source/cmGeneratorTarget.cxx

@@ -5858,7 +5858,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility(
   static const std::string strNumMax = "COMPATIBLE_INTERFACE_NUMBER_MAX";
   static const std::string strNumMax = "COMPATIBLE_INTERFACE_NUMBER_MAX";
 
 
   for (auto const& dep : deps) {
   for (auto const& dep : deps) {
-    if (!dep.Target) {
+    if (!dep.Target || dep.Target->GetType() == cmStateEnums::OBJECT_LIBRARY) {
       continue;
       continue;
     }
     }
 
 

+ 7 - 0
Source/cmGlobalXCodeGenerator.cxx

@@ -3598,6 +3598,13 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
       continue;
       continue;
     }
     }
     for (auto const& libItem : cli->GetItems()) {
     for (auto const& libItem : cli->GetItems()) {
+      // Explicitly ignore OBJECT libraries as Xcode emulates them as static
+      // libraries without an artifact. Avoid exposing this to the rest of
+      // CMake's compilation model.
+      if (libItem.Target &&
+          libItem.Target->GetType() == cmStateEnums::OBJECT_LIBRARY) {
+        continue;
+      }
       // We want to put only static libraries, dynamic libraries, frameworks
       // We want to put only static libraries, dynamic libraries, frameworks
       // and bundles that are built from targets that are not imported in "Link
       // and bundles that are built from targets that are not imported in "Link
       // Binary With Libraries" build phase. Except if the target property
       // Binary With Libraries" build phase. Except if the target property

+ 2 - 1
Source/cmLinkLineComputer.cxx

@@ -65,7 +65,8 @@ void cmLinkLineComputer::ComputeLinkLibs(
   ItemVector const& items = cli.GetItems();
   ItemVector const& items = cli.GetItems();
   for (auto const& item : items) {
   for (auto const& item : items) {
     if (item.Target &&
     if (item.Target &&
-        item.Target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+        (item.Target->GetType() == cmStateEnums::INTERFACE_LIBRARY ||
+         item.Target->GetType() == cmStateEnums::OBJECT_LIBRARY)) {
       continue;
       continue;
     }
     }
 
 

+ 1 - 0
Source/cmLinkLineDeviceComputer.cxx

@@ -115,6 +115,7 @@ void cmLinkLineDeviceComputer::ComputeLinkLibraries(
       switch (item.Target->GetType()) {
       switch (item.Target->GetType()) {
         case cmStateEnums::SHARED_LIBRARY:
         case cmStateEnums::SHARED_LIBRARY:
         case cmStateEnums::MODULE_LIBRARY:
         case cmStateEnums::MODULE_LIBRARY:
+        case cmStateEnums::OBJECT_LIBRARY:
         case cmStateEnums::INTERFACE_LIBRARY:
         case cmStateEnums::INTERFACE_LIBRARY:
           skip = true;
           skip = true;
           break;
           break;

+ 2 - 1
Source/cmLocalVisualStudio7Generator.cxx

@@ -1318,7 +1318,8 @@ void cmLocalVisualStudio7GeneratorInternals::OutputLibraries(
       fout << (lib.HasFeature() ? lib.GetFormattedItem(rel).Value : rel)
       fout << (lib.HasFeature() ? lib.GetFormattedItem(rel).Value : rel)
            << " ";
            << " ";
     } else if (!lib.Target ||
     } else if (!lib.Target ||
-               lib.Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
+               (lib.Target->GetType() != cmStateEnums::INTERFACE_LIBRARY &&
+                lib.Target->GetType() != cmStateEnums::OBJECT_LIBRARY)) {
       fout << lib.Value.Value << " ";
       fout << lib.Value.Value << " ";
     }
     }
   }
   }

+ 2 - 1
Source/cmVisualStudio10TargetGenerator.cxx

@@ -4603,7 +4603,8 @@ void cmVisualStudio10TargetGenerator::AddLibraries(
                                         : path);
                                         : path);
       }
       }
     } else if (!l.Target ||
     } else if (!l.Target ||
-               l.Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
+               (l.Target->GetType() != cmStateEnums::INTERFACE_LIBRARY &&
+                l.Target->GetType() != cmStateEnums::OBJECT_LIBRARY)) {
       libVec.push_back(l.Value.Value);
       libVec.push_back(l.Value.Value);
     }
     }
   }
   }