1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
3 #include "cmExportSet.h"
9 #include "cmGeneratorTarget.h"
10 #include "cmLocalGenerator.h"
11 #include "cmMessageType.h"
12 #include "cmStringAlgorithms.h"
14 #include "cmTargetExport.h"
16 cmExportSet::cmExportSet(std::string name)
17 : Name(std::move(name))
21 cmExportSet::~cmExportSet() = default;
23 bool cmExportSet::Compute(cmLocalGenerator* lg)
25 for (std::unique_ptr<cmTargetExport>& tgtExport : this->TargetExports) {
26 tgtExport->Target = lg->FindGeneratorTargetToUse(tgtExport->TargetName);
28 auto const interfaceFileSets =
29 tgtExport->Target->Target->GetAllInterfaceFileSets();
30 auto const fileSetInTargetExport =
31 [&tgtExport, lg](const std::string& fileSetName) -> bool {
32 auto* fileSet = tgtExport->Target->Target->GetFileSet(fileSetName);
34 if (!tgtExport->FileSetGenerators.count(fileSet)) {
35 lg->IssueMessage(MessageType::FATAL_ERROR,
36 cmStrCat("File set \"", fileSetName,
37 "\" is listed in interface file sets of ",
38 tgtExport->Target->GetName(),
39 " but has not been exported"));
45 if (!std::all_of(interfaceFileSets.begin(), interfaceFileSets.end(),
46 fileSetInTargetExport)) {
54 void cmExportSet::AddTargetExport(std::unique_ptr<cmTargetExport> te)
56 this->TargetExports.emplace_back(std::move(te));
59 void cmExportSet::AddInstallation(cmInstallExportGenerator const* installation)
61 this->Installations.push_back(installation);
64 cmExportSet& cmExportSetMap::operator[](const std::string& name)
66 auto it = this->find(name);
67 if (it == this->end()) // Export set not found
69 auto tup_name = std::make_tuple(name);
70 it = this->emplace(std::piecewise_construct, tup_name, tup_name).first;