summaryrefslogtreecommitdiffstats
path: root/Source/cmCommonTargetGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-11-14 17:04:01 (GMT)
committerBrad King <brad.king@kitware.com>2023-11-14 18:50:13 (GMT)
commit0e26bd334db07e481e5585f5121fb7e9718e9c47 (patch)
treeac8ec807ab94b37ee73972f034f7458f134fc694 /Source/cmCommonTargetGenerator.cxx
parent257d6766c634af351a1da994fd163bacfa5bf82b (diff)
downloadCMake-0e26bd334db07e481e5585f5121fb7e9718e9c47.zip
CMake-0e26bd334db07e481e5585f5121fb7e9718e9c47.tar.gz
CMake-0e26bd334db07e481e5585f5121fb7e9718e9c47.tar.bz2
cmCommonTargetGenerator: Factor out GetLinkedTargetDirectories loop body
Re-use the body in multiple loops instead of allocating to combine them.
Diffstat (limited to 'Source/cmCommonTargetGenerator.cxx')
-rw-r--r--Source/cmCommonTargetGenerator.cxx17
1 files changed, 8 insertions, 9 deletions
diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx
index c781137..e9233b6 100644
--- a/Source/cmCommonTargetGenerator.cxx
+++ b/Source/cmCommonTargetGenerator.cxx
@@ -170,15 +170,8 @@ std::vector<std::string> cmCommonTargetGenerator::GetLinkedTargetDirectories(
cmGlobalCommonGenerator* const gg = this->GlobalCommonGenerator;
if (cmComputeLinkInformation* cli =
this->GeneratorTarget->GetLinkInformation(config)) {
- std::vector<cmGeneratorTarget const*> targets;
- for (auto const& item : cli->GetItems()) {
- targets.push_back(item.Target);
- }
- for (auto const* target : cli->GetObjectLibrariesLinked()) {
- targets.push_back(target);
- }
-
- for (auto const* linkee : targets) {
+ auto addLinkedTarget = [this, &lang, &config, &dirs, &emitted,
+ gg](cmGeneratorTarget const* linkee) {
if (linkee &&
!linkee->IsImported()
// Skip targets that build after this one in a static lib cycle.
@@ -200,6 +193,12 @@ std::vector<std::string> cmCommonTargetGenerator::GetLinkedTargetDirectories(
}
dirs.push_back(std::move(di));
}
+ };
+ for (auto const& item : cli->GetItems()) {
+ addLinkedTarget(item.Target);
+ }
+ for (cmGeneratorTarget const* target : cli->GetObjectLibrariesLinked()) {
+ addLinkedTarget(target);
}
}
return dirs;