mirror of
https://github.com/Kitware/CMake.git
synced 2026-11-06 05:16:58 +00:00
install(SBOM) could crash for dependencies outside an export set and mishandle private dependencies expressed through LINK_ONLY. Resolve link expressions before target lookup, traverse unexported dependencies transitively, and isolate document state per configuration. Preserve target license precedence and align document metadata inheritance with CPS. Add regression coverage for these cases. Fixes: #28141 Fixes: #28210
69 lines
2.4 KiB
C++
69 lines
2.4 KiB
C++
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
file LICENSE.rst or https://cmake.org/licensing for details. */
|
|
#pragma once
|
|
|
|
#include "cmConfigure.h" // IWYU pragma: keep
|
|
|
|
#include <iosfwd>
|
|
#include <map>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "cmInstallGenerator.h"
|
|
|
|
class cmDiagnosticContext;
|
|
class cmExportSet;
|
|
class cmGeneratorTarget;
|
|
class cmInstallSbomBuilder;
|
|
class cmLocalGenerator;
|
|
class cmSbomArguments;
|
|
|
|
/** \class cmInstallSbomGenerator
|
|
* \brief Generate installation rules for SBOM files.
|
|
*
|
|
* At generate time it builds each configuration's SBOM in a temporary file;
|
|
* the cmake_install.cmake script then copies that file to the install
|
|
* destination.
|
|
*/
|
|
class cmInstallSbomGenerator : public cmInstallGenerator
|
|
{
|
|
public:
|
|
cmInstallSbomGenerator(std::vector<cmExportSet*> const& exportSets,
|
|
std::string destination, std::string filePermissions,
|
|
std::vector<std::string> const& configurations,
|
|
std::string component, MessageLevel message,
|
|
bool excludeFromAll, cmSbomArguments const& args,
|
|
cmDiagnosticContext context);
|
|
cmInstallSbomGenerator(cmInstallSbomGenerator const&) = delete;
|
|
~cmInstallSbomGenerator() override;
|
|
|
|
cmInstallSbomGenerator& operator=(cmInstallSbomGenerator const&) = delete;
|
|
|
|
bool Compute(cmLocalGenerator* lg) override;
|
|
|
|
std::string const& GetInstallFile() const { return this->SbomFilePath; }
|
|
|
|
/** True if this SBOM directly describes `target`. Used by peer SBOMs to
|
|
* attribute cross-references when install(export) provenance is absent. */
|
|
bool CoversTarget(cmGeneratorTarget const* target) const;
|
|
std::string const& GetPackageName() const;
|
|
|
|
/** True if `set` is one of the export sets this SBOM was built from.
|
|
* Used by the autogen path to skip sets already explicitly tied to an
|
|
* install(SBOM). */
|
|
bool CoversExportSet(cmExportSet const* set) const;
|
|
|
|
protected:
|
|
void GenerateScript(std::ostream& os) override;
|
|
void GenerateScriptActions(std::ostream& os, Indent indent) override;
|
|
|
|
private:
|
|
std::map<std::string, std::string> TempSbomFiles;
|
|
std::string const FilePermissions;
|
|
std::string const SbomFileName;
|
|
std::string const SbomFilePath;
|
|
cmLocalGenerator const* LocalGenerator = nullptr;
|
|
std::unique_ptr<cmInstallSbomBuilder> Builder;
|
|
};
|