Coverage Report

Created: 2026-03-12 06:35

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
  cmSpdxCreationInfo const* ci =
35
0
    insert_back(doc.Graph, this->GenerateCreationInfo());
36
0
  cmSpdxDocument* project = insert_back(doc.Graph, this->GenerateSbom(ci));
37
0
  std::vector<TargetProperties> targets;
38
39
0
  for (auto const& exp : this->Exports) {
40
0
    cmGeneratorTarget const* target = exp.Target;
41
42
0
    ImportPropertyMap properties;
43
0
    this->PopulateInterfaceProperties(target, properties);
44
0
    this->PopulateInterfaceLinkLibrariesProperty(
45
0
      target, cmGeneratorExpression::BuildInterface, properties);
46
0
    this->PopulateLinkLibrariesProperty(
47
0
      target, cmGeneratorExpression::BuildInterface, properties);
48
49
0
    targets.push_back(
50
0
      TargetProperties{ insert_back(project->RootElements,
51
0
                                    this->GenerateImportTarget(ci, target)),
52
0
                        target, std::move(properties) });
53
0
  }
54
55
0
  for (auto const& target : targets) {
56
0
    this->GenerateProperties(doc, project, ci, target, targets);
57
0
  }
58
59
0
  this->WriteSbom(doc, os);
60
0
  return true;
61
0
}
62
63
void cmExportBuildSbomGenerator::HandleMissingTarget(
64
  std::string& /* link_libs */, cmGeneratorTarget const* /* depender */,
65
  cmGeneratorTarget* /* dependee */)
66
0
{
67
0
}
68
69
std::string cmExportBuildSbomGenerator::GetCxxModulesDirectory() const
70
0
{
71
0
  return {};
72
0
}
73
74
cm::string_view cmExportBuildSbomGenerator::GetImportPrefixWithSlash() const
75
0
{
76
0
  return "";
77
0
}
78
79
std::string cmExportBuildSbomGenerator::GetCxxModuleFile(
80
  std::string const& /*name*/) const
81
0
{
82
0
  return {};
83
0
}
84
85
void cmExportBuildSbomGenerator::GenerateCxxModuleConfigInformation(
86
  std::string const& /*name*/, std::ostream& /*os*/) const
87
0
{
88
  // TODO
89
0
}