summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Woehlke <matthew.woehlke@kitware.com>2024-07-18 16:44:12 (GMT)
committerMatthew Woehlke <matthew.woehlke@kitware.com>2024-07-23 16:13:39 (GMT)
commitff24058e46be5c8757da17602272e7668e6bd8ff (patch)
treef426ba377cd7bf0551d2c1b90be60355ae4b678e
parent20fa4ce8d89369441dc4f8a74d62611e8dfa36ea (diff)
downloadCMake-ff24058e46be5c8757da17602272e7668e6bd8ff.zip
CMake-ff24058e46be5c8757da17602272e7668e6bd8ff.tar.gz
CMake-ff24058e46be5c8757da17602272e7668e6bd8ff.tar.bz2
export: Use std::all_of to collect exports
Rewrite cmExport{Build,Install}FileGenerator::CollectExports to use std::all_of as recommended by clang-tidy.
-rw-r--r--Source/cmExportBuildFileGenerator.cxx17
-rw-r--r--Source/cmExportInstallFileGenerator.cxx18
2 files changed, 20 insertions, 15 deletions
diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx
index 73a4585..eefc516 100644
--- a/Source/cmExportBuildFileGenerator.cxx
+++ b/Source/cmExportBuildFileGenerator.cxx
@@ -115,20 +115,21 @@ void cmExportBuildFileGenerator::SetImportLocationProperty(
bool cmExportBuildFileGenerator::CollectExports(
std::function<void(cmGeneratorTarget const*)> visitor)
{
- std::vector<TargetExport> targets;
- this->GetTargets(targets);
- for (auto const& tei : targets) {
+ auto pred = [&](cmExportBuildFileGenerator::TargetExport& tei) -> bool {
cmGeneratorTarget* te = this->LG->FindGeneratorTargetToUse(tei.Name);
if (this->ExportedTargets.insert(te).second) {
this->Exports.emplace_back(te, tei.XcFrameworkLocation);
visitor(te);
- } else {
- this->ComplainAboutDuplicateTarget(te->GetName());
- return false;
+ return true;
}
- }
- return true;
+ this->ComplainAboutDuplicateTarget(te->GetName());
+ return false;
+ };
+
+ std::vector<TargetExport> targets;
+ this->GetTargets(targets);
+ return std::all_of(targets.begin(), targets.end(), pred);
}
void cmExportBuildFileGenerator::HandleMissingTarget(
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index 374b5ed..8738938 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmExportInstallFileGenerator.h"
+#include <algorithm>
#include <cassert>
#include <cstddef>
#include <memory>
@@ -313,18 +314,21 @@ std::string cmExportInstallFileGenerator::GetCxxModuleFile() const
bool cmExportInstallFileGenerator::CollectExports(
std::function<void(cmTargetExport const*)> const& visitor)
{
- for (auto const& te : this->GetExportSet()->GetTargetExports()) {
+ auto pred = [&](std::unique_ptr<cmTargetExport> const& te) -> bool {
if (te->NamelinkOnly) {
- continue;
+ return true;
}
if (this->ExportedTargets.insert(te->Target).second) {
visitor(te.get());
- } else {
- this->ComplainAboutDuplicateTarget(te->Target->GetName());
- return false;
+ return true;
}
- }
- return true;
+
+ this->ComplainAboutDuplicateTarget(te->Target->GetName());
+ return false;
+ };
+
+ auto const& targets = this->GetExportSet()->GetTargetExports();
+ return std::all_of(targets.begin(), targets.end(), pred);
}
bool cmExportInstallFileGenerator::PopulateInterfaceProperties(