summaryrefslogtreecommitdiffstats
path: root/Source/cmNinjaNormalTargetGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-10-01 17:31:41 (GMT)
committerBrad King <brad.king@kitware.com>2019-10-01 18:34:03 (GMT)
commit4891f0f9662d6e2b355717aa1f7250f3462229bb (patch)
tree6052be050944f9f7ac133a397d5d159e09556361 /Source/cmNinjaNormalTargetGenerator.cxx
parent62d65286e71c58c88646f2f851edf7669fd40a41 (diff)
downloadCMake-4891f0f9662d6e2b355717aa1f7250f3462229bb.zip
CMake-4891f0f9662d6e2b355717aa1f7250f3462229bb.tar.gz
CMake-4891f0f9662d6e2b355717aa1f7250f3462229bb.tar.bz2
Ninja: Ensure shared library version symlinks are created for dependents
When linking to a shared library target that has version symlinks, add an order-only dependency on the build statement that creates the links. This ensures that the links exist for use at runtime. Fixes: #19774
Diffstat (limited to 'Source/cmNinjaNormalTargetGenerator.cxx')
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx21
1 files changed, 21 insertions, 0 deletions
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index bd5abd1..38ccaa3 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -13,6 +13,7 @@
#include <cm/memory>
#include "cmAlgorithms.h"
+#include "cmComputeLinkInformation.h"
#include "cmCustomCommand.h" // IWYU pragma: keep
#include "cmCustomCommandGenerator.h"
#include "cmGeneratedFileStream.h"
@@ -1049,6 +1050,26 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
// Gather order-only dependencies.
this->GetLocalGenerator()->AppendTargetDepends(gt, linkBuild.OrderOnlyDeps);
+ // Add order-only dependencies on versioning symlinks of shared libs we link.
+ if (!this->GeneratorTarget->IsDLLPlatform()) {
+ if (cmComputeLinkInformation* cli =
+ this->GeneratorTarget->GetLinkInformation(this->GetConfigName())) {
+ for (auto const& item : cli->GetItems()) {
+ if (item.Target &&
+ item.Target->GetType() == cmStateEnums::SHARED_LIBRARY &&
+ !item.Target->IsFrameworkOnApple()) {
+ std::string const& lib = this->ConvertToNinjaPath(
+ item.Target->GetFullPath(this->GetConfigName()));
+ if (std::find(linkBuild.ImplicitDeps.begin(),
+ linkBuild.ImplicitDeps.end(),
+ lib) == linkBuild.ImplicitDeps.end()) {
+ linkBuild.OrderOnlyDeps.emplace_back(lib);
+ }
+ }
+ }
+ }
+ }
+
// Ninja should restat after linking if and only if there are byproducts.
vars["RESTAT"] = byproducts.empty() ? "" : "1";