From d8182105a1d62307aa5f5aa8388e074ecacf0773 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 17 Nov 2023 22:47:23 -0500 Subject: cmGeneratorTarget: add a query for targets with objects in the source list This will be eventually be used to inform the collator of this information so that Fortran modules provided by the resulting objects can also be used as intended. --- Source/cmGeneratorTarget.cxx | 27 ++++++++++++++++++--------- Source/cmGeneratorTarget.h | 5 +++++ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 333ed07..29d2af3 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -8052,21 +8052,30 @@ void cmGeneratorTarget::GetLanguages(std::set& languages, objectLibraries.insert(gt); } } else { - std::vector externalObjects; - this->GetExternalObjects(externalObjects, config); - for (cmSourceFile const* extObj : externalObjects) { - std::string objLib = extObj->GetObjectLibrary(); - if (cmGeneratorTarget* tgt = - this->LocalGenerator->FindGeneratorTargetToUse(objLib)) { - objectLibraries.insert(tgt); - } - } + objectLibraries = this->GetSourceObjectLibraries(config); } for (cmGeneratorTarget const* objLib : objectLibraries) { objLib->GetLanguages(languages, config); } } +std::set cmGeneratorTarget::GetSourceObjectLibraries( + std::string const& config) const +{ + std::set objectLibraries; + std::vector externalObjects; + this->GetExternalObjects(externalObjects, config); + for (cmSourceFile const* extObj : externalObjects) { + std::string objLib = extObj->GetObjectLibrary(); + if (cmGeneratorTarget* tgt = + this->LocalGenerator->FindGeneratorTargetToUse(objLib)) { + objectLibraries.insert(tgt); + } + } + + return objectLibraries; +} + bool cmGeneratorTarget::IsLanguageUsed(std::string const& language, std::string const& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index bf49914..2a301e3 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -463,6 +463,11 @@ public: bool IsLanguageUsed(std::string const& language, std::string const& config) const; + // Get the set of targets directly referenced via `TARGET_OBJECTS` in the + // source list for a configuration. + std::set GetSourceObjectLibraries( + std::string const& config) const; + bool IsCSharpOnly() const; bool IsDotNetSdkTarget() const; -- cgit v0.12