Coverage Report

Created: 2026-06-15 07:03

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/CMake/Source/cmInstallSbomGenerator.h
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
#pragma once
4
5
#include "cmConfigure.h" // IWYU pragma: keep
6
7
#include <iosfwd>
8
#include <map>
9
#include <memory>
10
#include <string>
11
#include <vector>
12
13
#include "cmInstallGenerator.h"
14
#include "cmSbomArguments.h"
15
16
class cmDiagnosticContext;
17
class cmExportSet;
18
class cmGeneratorTarget;
19
class cmInstallSbomBuilder;
20
class cmLocalGenerator;
21
22
/** \class cmInstallSbomGenerator
23
 * \brief Generate installation rules for SBOM files.
24
 *
25
 * Thin cmInstallGenerator subclass that owns a cmInstallSbomBuilder.
26
 * At generate time it writes the SBOM into a temporary file in the build tree;
27
 * the cmake_install.cmake script then copies that file to the install
28
 * destination.
29
 */
30
class cmInstallSbomGenerator : public cmInstallGenerator
31
{
32
public:
33
  cmInstallSbomGenerator(std::vector<cmExportSet*> exportSets,
34
                         std::string destination, std::string filePermissions,
35
                         std::vector<std::string> const& configurations,
36
                         std::string component, MessageLevel message,
37
                         bool excludeFromAll, cmSbomArguments args,
38
                         cmDiagnosticContext context);
39
  cmInstallSbomGenerator(cmInstallSbomGenerator const&) = delete;
40
  ~cmInstallSbomGenerator() override;
41
42
  cmInstallSbomGenerator& operator=(cmInstallSbomGenerator const&) = delete;
43
44
  bool Compute(cmLocalGenerator* lg) override;
45
46
0
  std::string const& GetInstallFile() const { return this->SbomFilePath; }
47
48
  /** True if this SBOM directly describes `target`.  Used by peer SBOMs to
49
   *  attribute cross-references when install(export) provenance is absent. */
50
  bool CoversTarget(cmGeneratorTarget const* target) const;
51
  std::string const& GetPackageName() const;
52
53
  /** True if `set` is one of the export sets this SBOM was built from.
54
   *  Used by the autogen path to skip sets already explicitly tied to an
55
   *  install(SBOM). */
56
  bool CoversExportSet(cmExportSet const* set) const;
57
58
protected:
59
  void GenerateScript(std::ostream& os) override;
60
  void GenerateScriptActions(std::ostream& os, Indent indent) override;
61
62
private:
63
  std::map<std::string, std::string> TempSbomFiles;
64
  std::string const FilePermissions;
65
  std::string const SbomFileName;
66
  std::string const SbomFilePath;
67
  cmSbomArguments::SbomFormat SbomFormat;
68
  cmLocalGenerator* LocalGenerator = nullptr;
69
  std::unique_ptr<cmInstallSbomBuilder> Builder;
70
};