Coverage Report

Created: 2026-02-09 06:05

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/CMake/Source/cmExportBuildSbomGenerator.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 "cmExportBuildSbomGenerator.h"
4
5
#include <functional>
6
#include <utility>
7
#include <vector>
8
9
#include <cmext/string_view>
10
11
#include "cmGeneratorExpression.h"
12
#include "cmSbomArguments.h"
13
#include "cmSbomObject.h"
14
#include "cmSpdx.h"
15
#include "cmStringAlgorithms.h"
16
17
class cmGeneratorTarget;
18
19
cmExportBuildSbomGenerator::cmExportBuildSbomGenerator(cmSbomArguments args)
20
0
  : cmExportSbomGenerator(args)
21
0
{
22
0
  this->SetNamespace(cmStrCat(this->GetPackageName(), "::"_s));
23
0
}
Unexecuted instantiation: cmExportBuildSbomGenerator::cmExportBuildSbomGenerator(cmSbomArguments)
Unexecuted instantiation: cmExportBuildSbomGenerator::cmExportBuildSbomGenerator(cmSbomArguments)
24
25
bool cmExportBuildSbomGenerator::GenerateMainFile(std::ostream& os)
26
0
{
27
0
  if (!this->CollectExports([&](cmGeneratorTarget const*) {})) {
28
0
    return false;
29
0
  }
30
31
0
  cmSbomDocument doc;
32
0
  doc.Graph.reserve(256);
33
34
0
  cmSpdxDocument* project = insert_back(doc.Graph, this->GenerateSbom());
35
0
  std::vector<TargetProperties> targets;
36
37
0
  for (auto const& exp : this->Exports) {
38
0
    cmGeneratorTarget const* target = exp.Target;
39
40
0
    ImportPropertyMap properties;
41
0
    this->PopulateInterfaceProperties(target, properties);
42
0
    this->PopulateInterfaceLinkLibrariesProperty(
43
0
      target, cmGeneratorExpression::BuildInterface, properties);
44
0
    this->PopulateLinkLibrariesProperty(
45
0
      target, cmGeneratorExpression::BuildInterface, properties);
46
47
0
    targets.push_back(TargetProperties{
48
0
      insert_back(project->RootElements, this->GenerateImportTarget(target)),
49
0
      target, std::move(properties) });
50
0
  }
51
52
0
  for (auto const& target : targets) {
53
0
    this->GenerateProperties(doc, project, target, targets);
54
0
  }
55
56
0
  this->WriteSbom(doc, os);
57
0
  return true;
58
0
}
59
60
void cmExportBuildSbomGenerator::HandleMissingTarget(
61
  std::string& /* link_libs */, cmGeneratorTarget const* /* depender */,
62
  cmGeneratorTarget* /* dependee */)
63
0
{
64
0
}
65
66
std::string cmExportBuildSbomGenerator::GetCxxModulesDirectory() const
67
0
{
68
0
  return {};
69
0
}
70
71
cm::string_view cmExportBuildSbomGenerator::GetImportPrefixWithSlash() const
72
0
{
73
0
  return "";
74
0
}
75
76
std::string cmExportBuildSbomGenerator::GetCxxModuleFile(
77
  std::string const& /*name*/) const
78
0
{
79
0
  return {};
80
0
}
81
82
void cmExportBuildSbomGenerator::GenerateCxxModuleConfigInformation(
83
  std::string const& /*name*/, std::ostream& /*os*/) const
84
0
{
85
  // TODO
86
0
}