From 03d86f9d9ce0d55ac297ea876245f0e5ac539cd0 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 5 Dec 2023 15:47:17 -0500 Subject: cmGeneratorTarget: Add helper to check for known runtime artifact --- Source/cmGeneratorTarget.cxx | 13 +++++++++++++ Source/cmGeneratorTarget.h | 1 + 2 files changed, 14 insertions(+) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4b4d8b9..45073f7 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1258,6 +1258,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; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 2a301e3..e6513a1 100644 --- a/Source/cmGeneratorTarget.h +++ b/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. */ -- cgit v0.12 From fc6508921cf291308b7270f19c14d373225bfd37 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 5 Dec 2023 15:50:17 -0500 Subject: cmComputeLinkInformation: Restore soname lookup for non-imported targets In commit 7351d590ee (cmTarget: Add a way to represent imported shared library stubs, 2023-07-17, v3.28.0-rc1~344^2) we accidentally stopped passing the SONAME of a non-imported SHARED library to our runtime search path ordering logic. Unfortunately I have not found a way to add a test case for this, but it at least shouldn't regress existing tests or those added by that commit. --- Source/cmComputeLinkInformation.cxx | 23 ++++++++++++----------- Source/cmGeneratorTarget.h | 1 - 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index c58dc68..1b69f6e 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/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); } } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index e6513a1..c13b2f6 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -1098,7 +1098,6 @@ private: std::string SharedDeps; }; - friend cmComputeLinkInformation; using ImportInfoMapType = std::map; mutable ImportInfoMapType ImportInfoMap; void ComputeImportInfo(std::string const& desired_config, -- cgit v0.12