| 164 | } |
| 165 | |
| 166 | cmCommonTargetGenerator::LinkedTargetDirs |
| 167 | cmCommonTargetGenerator::GetLinkedTargetDirectories( |
| 168 | std::string const& lang, std::string const& config) const |
| 169 | { |
| 170 | LinkedTargetDirs dirs; |
| 171 | std::set<cmGeneratorTarget const*> forward_emitted; |
| 172 | std::set<cmGeneratorTarget const*> direct_emitted; |
| 173 | cmGlobalCommonGenerator* const gg = this->GlobalCommonGenerator; |
| 174 | |
| 175 | enum class Forwarding |
| 176 | { |
| 177 | Yes, |
| 178 | No |
| 179 | }; |
| 180 | |
| 181 | if (cmComputeLinkInformation* cli = |
| 182 | this->GeneratorTarget->GetLinkInformation(config)) { |
| 183 | auto addLinkedTarget = |
| 184 | [this, &lang, &config, &dirs, &direct_emitted, &forward_emitted, |
| 185 | gg](cmGeneratorTarget const* linkee, Forwarding forward) { |
| 186 | if (linkee && |
| 187 | !linkee->IsImported() |
| 188 | // Skip targets that build after this one in a static lib cycle. |
| 189 | && gg->TargetOrderIndexLess(linkee, this->GeneratorTarget) |
| 190 | // We can ignore the INTERFACE_LIBRARY items because |
| 191 | // Target->GetLinkInformation already processed their |
| 192 | // link interface and they don't have any output themselves. |
| 193 | && (linkee->GetType() != cmStateEnums::INTERFACE_LIBRARY |
| 194 | // Synthesized targets may have relevant rules. |
| 195 | || linkee->IsSynthetic()) && |
| 196 | ((lang == "CXX"_s && linkee->HaveCxx20ModuleSources()) || |
| 197 | (lang == "Fortran"_s && linkee->HaveFortranSources(config)))) { |
| 198 | cmLocalGenerator* lg = linkee->GetLocalGenerator(); |
| 199 | std::string di = linkee->GetSupportDirectory(); |
| 200 | if (lg->GetGlobalGenerator()->IsMultiConfig()) { |
| 201 | di = cmStrCat(di, '/', config); |
| 202 | } |
| 203 | if (forward == Forwarding::Yes && |
| 204 | forward_emitted.insert(linkee).second) { |
| 205 | dirs.Forward.push_back(di); |
| 206 | } |
| 207 | if (direct_emitted.insert(linkee).second) { |
| 208 | dirs.Direct.emplace_back(di); |
| 209 | } |
| 210 | } |
| 211 | }; |
| 212 | for (auto const& item : cli->GetItems()) { |
| 213 | if (item.Target) { |
| 214 | addLinkedTarget(item.Target, Forwarding::No); |
| 215 | } else if (item.ObjectSource && lang == "Fortran"_s |
| 216 | /* Object source files do not have a language associated with |
| 217 | them. */ |
| 218 | /* && item.ObjectSource->GetLanguage() == "Fortran"_s*/) { |
| 219 | // Fortran modules provided by `$<TARGET_OBJECTS>` as linked items |
| 220 | // should be collated for use in this target. |
| 221 | addLinkedTarget(this->LocalCommonGenerator->FindGeneratorTargetToUse( |
| 222 | item.ObjectSource->GetObjectLibrary()), |
| 223 | Forwarding::Yes); |
no test coverage detected