CMake: Handle installing files with same name during SBOM generation
It's possible for a project to install a custom file with the same name into different destination directories, and want to include them in the SBOM. Previously this failed at CMake generation time with an error like: CMake Error: Files to be generated by multiple different commands: qt_sbom/SPDXRef-PackagedFile-foo-bar.cmake This happened due to using a non-unique filename for the generated SBOM building file, as well as the spdx id the file name is based on. Include a short hash based on the installed relative path of the file to avoid spdx id clashes, and thus generated file name clashes. Pick-to: 6.8 Task-number: QTBUG-122899 Change-Id: I4c2ecd4652708504ef299af9b6f53d680d542382 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 9245d0a0f0761364e7b5b3d1c5c96cba16522820) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
5fd8af81ad
commit
37c60080dd
@ -677,7 +677,12 @@ function(_qt_internal_sbom_add_custom_file target installed_file_relative_path)
|
||||
set(file_type "OTHER")
|
||||
endif()
|
||||
|
||||
# Append a short hash based on the installed relative path of the file, to avoid spdx id
|
||||
# clashes for files with the same name installed into different dirs.
|
||||
get_filename_component(file_name "${installed_file_relative_path}" NAME)
|
||||
string(SHA1 rel_path_hash "${installed_file_relative_path}")
|
||||
string(SUBSTRING "${rel_path_hash}" 0 4 short_hash)
|
||||
set(file_name "${file_name}-${short_hash}")
|
||||
|
||||
_qt_internal_sbom_get_package_infix("${arg_PACKAGE_TYPE}" package_infix)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user