SBOM: Support multi export set SBOMs

This commit is contained in:
Tom Osika
2026-06-01 12:27:13 -04:00
parent 9669829573
commit 273fc4cc49
124 changed files with 1856 additions and 894 deletions
+51
View File
@@ -24,8 +24,10 @@
#include "cmBuildOptions.h"
#include "cmCustomCommandLines.h"
#include "cmDuration.h"
#include "cmExportFileGenerator.h"
#include "cmExportSet.h"
#include "cmLocalGenerator.h"
#include "cmSbomBuilder.h"
#include "cmStateSnapshot.h"
#include "cmStateTypes.h"
#include "cmStringAlgorithms.h"
@@ -50,6 +52,8 @@ class cmBuildArgs;
class cmDirectoryId;
class cmExportBuildFileGenerator;
class cmExternalMakefileProjectGenerator;
class cmBuildSbomGenerator;
class cmInstallSbomGenerator;
class cmGeneratorTarget;
class cmInstallRuntimeDependencySet;
class cmLinkLineComputer;
@@ -635,9 +639,54 @@ public:
{
return this->BuildExportSets;
}
/** Scan all build-tree exports in the project and report which of them
* reference `target`. Used both by cmExportBuildFileGenerator (to resolve
* out-of-export link references) and by cmSbomBuilder (to record which
* export sets a target appears in for SBOM dependency tracking). */
cmExportFileGenerator::ExportInfo FindBuildExportInfo(
cmGeneratorTarget const* target) const;
/** Same as FindBuildExportInfo, but searches install-tree export sets
* (those registered via install(EXPORT ...)). */
cmExportFileGenerator::ExportInfo FindInstallExportInfo(
cmGeneratorTarget const* target) const;
/** Scan all build-tree SBOMs and report which of them cover `target`. */
cmSbomBuilder::SbomInfo FindBuildSbomInfo(
cmGeneratorTarget const* target) const;
/** Same as FindBuildSbomInfo, but searches install-tree SBOMs. */
cmSbomBuilder::SbomInfo FindInstallSbomInfo(
cmGeneratorTarget const* target) const;
void AddBuildExportSet(cmExportBuildFileGenerator* gen);
void AddBuildExportExportSet(cmExportBuildFileGenerator* gen);
void AddBuildSbomGenerator(cmBuildSbomGenerator* gen);
std::vector<cmBuildSbomGenerator*> const& GetBuildSbomGenerators() const
{
return this->BuildSbomGenerators;
}
// Project-wide registry of install(SBOM) generators.
void AddInstallSbomGenerator(cmInstallSbomGenerator const* gen);
std::vector<cmInstallSbomGenerator const*> const& GetInstallSbomGenerators()
const
{
return this->InstallSbomGenerators;
}
bool IsExportedTargetsFile(std::string const& filename) const;
/** True if any registered cmBuildSbomGenerator already targets this
* output file path. Used to diagnose duplicate `export(SBOM ...)`
* calls that would otherwise silently clobber each other's output. */
bool IsBuildSbomFile(std::string const& filepath) const;
/** True if any registered cmInstallSbomGenerator already targets this
* install file path (DESTINATION + filename). Used to diagnose
* duplicate `install(SBOM ...)` calls that would otherwise silently
* clobber each other at install time. */
bool IsInstallSbomFile(std::string const& filepath) const;
cmExportBuildFileGenerator* GetExportedTargetsFile(
std::string const& filename) const;
void AddCMP0068WarnTarget(std::string const& target);
@@ -824,6 +873,8 @@ protected:
cmExportSetMap ExportSets;
std::map<std::string, cmExportBuildFileGenerator*> BuildExportSets;
std::map<std::string, cmExportBuildFileGenerator*> BuildExportExportSets;
std::vector<cmBuildSbomGenerator*> BuildSbomGenerators;
std::vector<cmInstallSbomGenerator const*> InstallSbomGenerators;
std::map<std::string, std::string> AliasTargets;