| 192 | }; |
| 193 | |
| 194 | bool cmGeneratorTarget::ComputeLinkClosure(std::string const& config, |
| 195 | LinkClosure& lc, |
| 196 | bool secondPass) const |
| 197 | { |
| 198 | // Get languages built in this target. |
| 199 | std::unordered_set<std::string> languages; |
| 200 | cmLinkImplementation const* impl = |
| 201 | this->GetLinkImplementation(config, UseTo::Link, secondPass); |
| 202 | assert(impl); |
| 203 | languages.insert(impl->Languages.cbegin(), impl->Languages.cend()); |
| 204 | |
| 205 | // Add interface languages from linked targets. |
| 206 | // cmTargetCollectLinkLanguages linkLangs(this, config, languages, this, |
| 207 | // secondPass); |
| 208 | cmTargetCollectLinkLanguages linkLangs(this, config, languages, this, |
| 209 | secondPass); |
| 210 | for (cmLinkItem const& lib : impl->Libraries) { |
| 211 | linkLangs.Visit(lib); |
| 212 | } |
| 213 | |
| 214 | // Store the transitive closure of languages. |
| 215 | cm::append(lc.Languages, languages); |
| 216 | |
| 217 | // Choose the language whose linker should be used. |
| 218 | if (secondPass || lc.LinkerLanguage.empty()) { |
| 219 | // Find the language with the highest preference value. |
| 220 | cmTargetSelectLinker tsl(this); |
| 221 | |
| 222 | // First select from the languages compiled directly in this target. |
| 223 | for (std::string const& l : impl->Languages) { |
| 224 | tsl.Consider(l); |
| 225 | } |
| 226 | |
| 227 | // Now consider languages that propagate from linked targets. |
| 228 | for (std::string const& lang : languages) { |
| 229 | std::string propagates = |
| 230 | cmStrCat("CMAKE_", lang, "_LINKER_PREFERENCE_PROPAGATES"); |
| 231 | if (this->Makefile->IsOn(propagates)) { |
| 232 | tsl.Consider(lang); |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | lc.LinkerLanguage = tsl.Choose(); |
| 237 | } |
| 238 | |
| 239 | return impl->HadLinkLanguageSensitiveCondition || |
| 240 | linkLangs.GetHadLinkLanguageSensitiveCondition(); |
| 241 | } |
| 242 | |
| 243 | void cmGeneratorTarget::ComputeLinkClosure(std::string const& config, |
| 244 | LinkClosure& lc) const |
no test coverage detected