CMake: Allow creating nested SBOM attribution targets for all entities

Allow creating nested SBOM attribution targets also for non-Qt targets
in user projects. This will allow using qt_attribution.json files in
user projects.

Rename PARENT_TARGET to ATTRIBUTION_PARENT_TARGET to make it clear
what the parent target is for.

Pick-to: 6.8
Task-number: QTBUG-122899
Change-Id: Ia08ee934a9dc03827fcc26d0fc90e072499e8a21
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit a2ddd4fbd88353b21617e539266196b592683a3a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Alexandru Croitor 2025-02-24 16:42:00 +01:00 committed by Qt Cherry-pick Bot
parent 21c5970da4
commit c276fa45dc
2 changed files with 13 additions and 12 deletions

View File

@ -25,12 +25,8 @@ function(_qt_internal_sbom_handle_qt_attribution_files out_prefix_outer)
return()
endif()
set(opt_args
CREATE_SBOM_FOR_EACH_ATTRIBUTION
)
set(single_args
PARENT_TARGET
)
set(opt_args "")
set(single_args "")
set(multi_args "")
_qt_internal_get_sbom_specific_options(sbom_opt_args sbom_single_args sbom_multi_args)
@ -64,8 +60,8 @@ function(_qt_internal_sbom_handle_qt_attribution_files out_prefix_outer)
set(propagate_sbom_options_to_new_attribution_targets TRUE)
if(arg_CREATE_SBOM_FOR_EACH_ATTRIBUTION)
set(propagate_sbom_options_to_new_attribution_targets FALSE)
if(NOT arg_PARENT_TARGET)
message(FATAL_ERROR "PARENT_TARGET must be set")
if(NOT arg_ATTRIBUTION_PARENT_TARGET)
message(FATAL_ERROR "ATTRIBUTION_PARENT_TARGET must be set")
endif()
endif()
@ -185,7 +181,7 @@ function(_qt_internal_sbom_handle_qt_attribution_files out_prefix_outer)
# If no Id was retrieved, just add a numeric one, to make the sbom target
# unique.
set(attribution_target "${arg_PARENT_TARGET}_Attribution_")
set(attribution_target "${arg_ATTRIBUTION_PARENT_TARGET}_Attribution_")
if(NOT ${out_prefix}_attribution_id)
string(APPEND attribution_target "${file_index}_${entry_index}")
else()
@ -222,7 +218,10 @@ function(_qt_internal_sbom_handle_qt_attribution_files out_prefix_outer)
# depending on which file and index is currently being processed.
_qt_internal_get_sbom_specific_options(
sbom_opt_args sbom_single_args sbom_multi_args)
list(REMOVE_ITEM sbom_opt_args NO_CURRENT_DIR_ATTRIBUTION)
list(REMOVE_ITEM sbom_opt_args
NO_CURRENT_DIR_ATTRIBUTION
CREATE_SBOM_FOR_EACH_ATTRIBUTION
)
list(REMOVE_ITEM sbom_single_args ATTRIBUTION_ENTRY_INDEX)
list(REMOVE_ITEM sbom_multi_args
ATTRIBUTION_IDS
@ -259,7 +258,7 @@ function(_qt_internal_sbom_handle_qt_attribution_files out_prefix_outer)
${sbom_args}
)
_qt_internal_extend_sbom_dependencies(${arg_PARENT_TARGET}
_qt_internal_extend_sbom_dependencies(${arg_ATTRIBUTION_PARENT_TARGET}
SBOM_DEPENDENCIES ${attribution_target}
)
endif()

View File

@ -545,6 +545,7 @@ macro(_qt_internal_get_sbom_add_target_common_options opt_args single_args multi
SBOM_INCOMPLETE_3RD_PARTY_DEPENDENCIES
IS_QT_3RD_PARTY_HEADER_MODULE
USE_ATTRIBUTION_FILES
CREATE_SBOM_FOR_EACH_ATTRIBUTION
__QT_INTERNAL_HANDLE_QT_ENTITY_TYPE_PACKAGE_VERSION
__QT_INTERNAL_HANDLE_QT_ENTITY_TYPE_SUPPLIER
__QT_INTERNAL_HANDLE_QT_ENTITY_TYPE_DOWNLOAD_LOCATION
@ -563,6 +564,7 @@ macro(_qt_internal_get_sbom_add_target_common_options opt_args single_args multi
QT_LICENSE_ID
DOWNLOAD_LOCATION
ATTRIBUTION_ENTRY_INDEX
ATTRIBUTION_PARENT_TARGET
SBOM_PACKAGE_COMMENT
)
set(${multi_args}
@ -694,7 +696,7 @@ function(_qt_internal_sbom_add_target target)
if(arg_USE_ATTRIBUTION_FILES)
set(attribution_args
PARENT_TARGET "${target}"
ATTRIBUTION_PARENT_TARGET "${target}"
)
if(is_qt_entity_type AND arg___QT_INTERNAL_HANDLE_QT_ENTITY_ATTRIBUTION_FILES)