diff options
author | Brad King <brad.king@kitware.com> | 2023-03-27 13:51:45 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2023-03-27 13:51:58 (GMT) |
commit | 381327c944dc60ccc418e110c5afee85462cfea4 (patch) | |
tree | 82783869aace757d4bfd1480b63e5c5f1dc9aa63 /Source | |
parent | fae6e8c2cdb5ce6049439f4defd1367b507d1e4b (diff) | |
parent | 01d7860fdb078dae5198056930e8cfd2ce532d84 (diff) | |
download | CMake-381327c944dc60ccc418e110c5afee85462cfea4.zip CMake-381327c944dc60ccc418e110c5afee85462cfea4.tar.gz CMake-381327c944dc60ccc418e110c5afee85462cfea4.tar.bz2 |
Merge topic 'module-depends-static-lib-cycle' into release-3.26
01d7860fdb Ninja,Makefile: Restore Fortran module scanning in static library cycle
846baa7c5b cmGlobalGenerator: Factor out helper to check target ordering
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !8363
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmCommonTargetGenerator.cxx | 3 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 9 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.h | 5 |
3 files changed, 15 insertions, 2 deletions
diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index a065ba9..6be0fa3 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -164,6 +164,7 @@ std::vector<std::string> cmCommonTargetGenerator::GetLinkedTargetDirectories( { std::vector<std::string> dirs; std::set<cmGeneratorTarget const*> emitted; + cmGlobalCommonGenerator* const gg = this->GlobalCommonGenerator; if (cmComputeLinkInformation* cli = this->GeneratorTarget->GetLinkInformation(config)) { cmComputeLinkInformation::ItemVector const& items = cli->GetItems(); @@ -171,6 +172,8 @@ std::vector<std::string> cmCommonTargetGenerator::GetLinkedTargetDirectories( cmGeneratorTarget const* linkee = item.Target; if (linkee && !linkee->IsImported() + // Skip targets that build after this one in a static lib cycle. + && gg->TargetOrderIndexLess(linkee, this->GeneratorTarget) // We can ignore the INTERFACE_LIBRARY items because // Target->GetLinkInformation already processed their // link interface and they don't have any output themselves. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 4cfec22..b55fcb8 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1719,8 +1719,7 @@ cmGlobalGenerator::GetLocalGeneratorTargetsInOrder(cmLocalGenerator* lg) const cm::append(gts, lg->GetGeneratorTargets()); std::sort(gts.begin(), gts.end(), [this](cmGeneratorTarget const* l, cmGeneratorTarget const* r) { - return this->TargetOrderIndex.at(l) < - this->TargetOrderIndex.at(r); + return this->TargetOrderIndexLess(l, r); }); return gts; } @@ -3060,6 +3059,12 @@ cmGlobalGenerator::GetTargetDirectDepends(cmGeneratorTarget const* target) return this->TargetDependencies[target]; } +bool cmGlobalGenerator::TargetOrderIndexLess(cmGeneratorTarget const* l, + cmGeneratorTarget const* r) const +{ + return this->TargetOrderIndex.at(l) < this->TargetOrderIndex.at(r); +} + bool cmGlobalGenerator::IsReservedTarget(std::string const& name) { // The following is a list of targets reserved diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 66ab752..f4862a0 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -479,6 +479,11 @@ public: TargetDependSet const& GetTargetDirectDepends( const cmGeneratorTarget* target); + // Return true if target 'l' occurs before 'r' in a global ordering + // of targets that respects inter-target dependencies. + bool TargetOrderIndexLess(cmGeneratorTarget const* l, + cmGeneratorTarget const* r) const; + const std::map<std::string, std::vector<cmLocalGenerator*>>& GetProjectMap() const { |