Răsfoiți Sursa

Merge topic 'imported-implib-only'

fc6508921c cmComputeLinkInformation: Restore soname lookup for non-imported targets
03d86f9d9c cmGeneratorTarget: Add helper to check for known runtime artifact

Acked-by: Kitware Robot <[email protected]>
Acked-by: buildbot <[email protected]>
Acked-by: Robert Maynard <[email protected]>
Merge-request: !9041
Brad King 1 an în urmă
părinte
comite
fb54e957d6

+ 12 - 11
Source/cmComputeLinkInformation.cxx

@@ -2363,20 +2363,21 @@ void cmComputeLinkInformation::AddLibraryRuntimeInfo(
   if (target->GetType() != cmStateEnums::SHARED_LIBRARY) {
     return;
   }
-  auto const* info = target->GetImportInfo(this->Config);
+
+  // Skip targets that do not have a known runtime artifact.
+  if (!target->HasKnownRuntimeArtifactLocation(this->Config)) {
+    return;
+  }
 
   // Try to get the soname of the library.  Only files with this name
   // could possibly conflict.
-  const char* soname =
-    (!info || info->SOName.empty()) ? nullptr : info->SOName.c_str();
-
-  // If this shared library has a known runtime artifact (IMPORTED_LOCATION),
-  // include its location in the runtime path ordering.
-  if (!info || !info->Location.empty()) {
-    this->OrderRuntimeSearchPath->AddRuntimeLibrary(fullPath, soname);
-    if (this->LinkWithRuntimePath) {
-      this->OrderLinkerSearchPath->AddRuntimeLibrary(fullPath, soname);
-    }
+  std::string soName = target->GetSOName(this->Config);
+  const char* soname = soName.empty() ? nullptr : soName.c_str();
+
+  // Include this library in the runtime path ordering.
+  this->OrderRuntimeSearchPath->AddRuntimeLibrary(fullPath, soname);
+  if (this->LinkWithRuntimePath) {
+    this->OrderLinkerSearchPath->AddRuntimeLibrary(fullPath, soname);
   }
 }
 

+ 13 - 0
Source/cmGeneratorTarget.cxx

@@ -1283,6 +1283,19 @@ bool cmGeneratorTarget::CanCompileSources() const
   return this->Target->CanCompileSources();
 }
 
+bool cmGeneratorTarget::HasKnownRuntimeArtifactLocation(
+  std::string const& config) const
+{
+  if (!this->IsRuntimeBinary()) {
+    return false;
+  }
+  if (!this->IsImported()) {
+    return true;
+  }
+  ImportInfo const* info = this->GetImportInfo(config);
+  return info && !info->Location.empty();
+}
+
 const std::string& cmGeneratorTarget::GetLocationForBuild() const
 {
   static std::string location;

+ 1 - 1
Source/cmGeneratorTarget.h

@@ -58,6 +58,7 @@ public:
   bool IsImported() const;
   bool IsImportedGloballyVisible() const;
   bool CanCompileSources() const;
+  bool HasKnownRuntimeArtifactLocation(std::string const& config) const;
   const std::string& GetLocation(const std::string& config) const;
 
   /** Get the full path to the target's main artifact, if known.  */
@@ -1107,7 +1108,6 @@ private:
     std::string SharedDeps;
   };
 
-  friend cmComputeLinkInformation;
   using ImportInfoMapType = std::map<std::string, ImportInfo>;
   mutable ImportInfoMapType ImportInfoMap;
   void ComputeImportInfo(std::string const& desired_config,