Browse Source

cmCommonTargetGenerator: use modules from object-referenced targets

Fortran modules provided by objects added as sources via
`$<TARGET_OBJECTS>` should also be considered as "linked targets" for
collation purposes. As C++ modules have their own visibility rules
through their `FILE_SET` feature, do not expose these for C++ module
collation.
Ben Boeckel 1 year ago
parent
commit
515ca5fcd1
1 changed files with 8 additions and 0 deletions
  1. 8 0
      Source/cmCommonTargetGenerator.cxx

+ 8 - 0
Source/cmCommonTargetGenerator.cxx

@@ -201,6 +201,14 @@ std::vector<std::string> cmCommonTargetGenerator::GetLinkedTargetDirectories(
     for (cmGeneratorTarget const* target : cli->GetExternalObjectTargets()) {
       addLinkedTarget(target);
     }
+    if (lang == "Fortran"_s) {
+      // Fortran modules provided by `$<TARGET_OBJECTS>` as sources should be
+      // collated for use in this target.
+      for (cmGeneratorTarget const* target :
+           this->GeneratorTarget->GetSourceObjectLibraries(config)) {
+        addLinkedTarget(target);
+      }
+    }
   }
   return dirs;
 }