Coverage Report

Created: 2026-02-09 06:05

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/CMake/Source/cmExportSet.cxx
Line
Count
Source
1
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2
   file LICENSE.rst or https://cmake.org/licensing for details.  */
3
#include "cmExportSet.h" // IWYU pragma: associated
4
5
#include <algorithm>
6
#include <tuple>
7
#include <utility>
8
9
#include "cmGeneratorTarget.h"
10
#include "cmLocalGenerator.h"
11
#include "cmMessageType.h"
12
#include "cmStringAlgorithms.h"
13
#include "cmTarget.h"
14
#include "cmTargetExport.h" // IWYU pragma: associated
15
16
cmExportSet::cmExportSet(std::string name)
17
0
  : Name(std::move(name))
18
0
{
19
0
}
20
21
0
cmExportSet::~cmExportSet() = default;
22
23
cmExportSet::PackageDependency& cmExportSet::GetPackageDependencyForSetup(
24
  std::string const& name)
25
0
{
26
0
  auto& dep = this->PackageDependencies[name];
27
0
  if (!dep.SpecifiedIndex) {
28
0
    dep.SpecifiedIndex = this->NextPackageDependencyIndex;
29
0
    this->NextPackageDependencyIndex++;
30
0
  }
31
0
  return dep;
32
0
}
33
34
bool cmExportSet::Compute(cmLocalGenerator* lg)
35
0
{
36
0
  for (std::unique_ptr<cmTargetExport>& tgtExport : this->TargetExports) {
37
0
    tgtExport->Target = lg->FindGeneratorTargetToUse(tgtExport->TargetName);
38
39
0
    auto const interfaceFileSets =
40
0
      tgtExport->Target->Target->GetAllInterfaceFileSets();
41
0
    auto const fileSetInTargetExport =
42
0
      [&tgtExport, lg](std::string const& fileSetName) -> bool {
43
0
      if (tgtExport->FileSetGenerators.find(fileSetName) ==
44
0
          tgtExport->FileSetGenerators.end()) {
45
0
        lg->IssueMessage(MessageType::FATAL_ERROR,
46
0
                         cmStrCat("File set \"", fileSetName,
47
0
                                  "\" is listed in interface file sets of ",
48
0
                                  tgtExport->Target->GetName(),
49
0
                                  " but has not been exported"));
50
0
        return false;
51
0
      }
52
0
      return true;
53
0
    };
54
55
0
    if (!std::all_of(interfaceFileSets.begin(), interfaceFileSets.end(),
56
0
                     fileSetInTargetExport)) {
57
0
      return false;
58
0
    }
59
0
  }
60
61
0
  return true;
62
0
}
63
64
void cmExportSet::AddTargetExport(std::unique_ptr<cmTargetExport> te)
65
0
{
66
0
  this->TargetExports.emplace_back(std::move(te));
67
0
}
68
69
void cmExportSet::AddInstallation(cmInstallExportGenerator const* installation)
70
0
{
71
0
  this->Installations.push_back(installation);
72
0
}
73
74
void cmExportSet::SetXcFrameworkLocation(std::string const& name,
75
                                         std::string const& location)
76
0
{
77
0
  for (auto& te : this->TargetExports) {
78
0
    if (name == te->TargetName) {
79
0
      te->XcFrameworkLocation = location;
80
0
    }
81
0
  }
82
0
}
83
84
cmExportSet& cmExportSetMap::operator[](std::string const& name)
85
0
{
86
0
  auto it = this->find(name);
87
0
  if (it == this->end()) // Export set not found
88
0
  {
89
0
    auto tup_name = std::make_tuple(name);
90
0
    it = this->emplace(std::piecewise_construct, tup_name, tup_name).first;
91
0
  }
92
0
  return it->second;
93
0
}