summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2023-11-18 03:47:23 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2023-11-21 14:42:58 (GMT)
commitd8182105a1d62307aa5f5aa8388e074ecacf0773 (patch)
treed6f84e777b08b929fbfc5dc19523fe730d80b0d7
parentee4e85e615aa21323f4d5c88a162e4ddc1e83c46 (diff)
downloadCMake-d8182105a1d62307aa5f5aa8388e074ecacf0773.zip
CMake-d8182105a1d62307aa5f5aa8388e074ecacf0773.tar.gz
CMake-d8182105a1d62307aa5f5aa8388e074ecacf0773.tar.bz2
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.
-rw-r--r--Source/cmGeneratorTarget.cxx27
-rw-r--r--Source/cmGeneratorTarget.h5
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<std::string>& languages,
objectLibraries.insert(gt);
}
} else {
- std::vector<cmSourceFile const*> 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 const*> cmGeneratorTarget::GetSourceObjectLibraries(
+ std::string const& config) const
+{
+ std::set<cmGeneratorTarget const*> objectLibraries;
+ std::vector<cmSourceFile const*> 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<cmGeneratorTarget const*> GetSourceObjectLibraries(
+ std::string const& config) const;
+
bool IsCSharpOnly() const;
bool IsDotNetSdkTarget() const;