MCPcopy Create free account
hub / github.com/Kitware/CMake / HandleSbomMode

Function HandleSbomMode

Source/cmInstallCommand.cxx:2509–2594  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2507}
2508
2509bool HandleSbomMode(std::vector<std::string> const& args,
2510 cmExecutionStatus& status)
2511{
2512#ifndef CMAKE_BOOTSTRAP
2513 if (!cmExperimental::HasSupportEnabled(
2514 status.GetMakefile(), cmExperimental::Feature::GenerateSbom)) {
2515 status.SetError("does not recognize sub-command SBOM");
2516 return false;
2517 }
2518
2519 Helper helper(status);
2520 cmInstallCommandArguments ica(helper.DefaultComponentName, *helper.Makefile);
2521
2522 cmSbomArguments arguments;
2523 ArgumentParser::NonEmpty<std::string> exportName;
2524 ArgumentParser::NonEmpty<std::string> cxxModulesDirectory;
2525
2526 arguments.Bind(ica);
2527 ica.Bind("EXPORT"_s, exportName);
2528 // ica.Bind("CXX_MODULES_DIRECTORY"_s, cxxModulesDirectory); TODO?
2529
2530 std::vector<std::string> unknownArgs;
2531 ica.Parse(args, &unknownArgs);
2532
2533 ArgumentParser::ParseResult result = ica.Parse(args, &unknownArgs);
2534 if (!result.Check(args[0], &unknownArgs, status)) {
2535 return false;
2536 }
2537
2538 if (!ica.Finalize()) {
2539 return false;
2540 }
2541
2542 if (arguments.PackageName.empty()) {
2543 // TODO: Fix our use of the parser to enforce this.
2544 status.SetError(cmStrCat(args[0], " missing SBOM name."));
2545 return false;
2546 }
2547
2548 if (exportName.empty()) {
2549 status.SetError(cmStrCat(args[0], " missing EXPORT."));
2550 return false;
2551 }
2552
2553 if (!arguments.Check(status) || !arguments.SetMetadataFromProject(status)) {
2554 return false;
2555 }
2556
2557 // Get or construct the destination path.
2558 std::string dest = ica.GetDestination();
2559 if (dest.empty()) {
2560 if (helper.Makefile->GetSafeDefinition("CMAKE_SYSTEM_NAME") == "Windows") {
2561 dest = arguments.GetDefaultDestination();
2562 } else {
2563 dest =
2564 arguments.GetDefaultDestination(helper.GetLibraryDestination(nullptr));
2565 }
2566 }

Callers

nothing calls this directly

Calls 15

moveFunction · 0.85
GetLibraryDestinationMethod · 0.80
AddInstallComponentMethod · 0.80
GetPermissionsMethod · 0.80
cmStrCatFunction · 0.70
GetMakefileMethod · 0.45
SetErrorMethod · 0.45
BindMethod · 0.45
ParseMethod · 0.45
CheckMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…