CMake: Unqtify THIRD_PARTY_SOURCES handling for SBOM attributions

Nested SBOM attribution targets were always created with the
QT_THIRD_PARTY_SOURCES type even in user projects.
Set an appropriate type depending on whether we are handling a qt
entity type or not.

Task-number: QTBUG-122899
Change-Id: Id8144d1b8093de78f2987a611a6de8e6d4777084
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit 0d9106bf7670b08c4bae11c3986b9cf3e0818b52)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 1f8a8da7c2a2618c62679c971101c363a38da476)
This commit is contained in:
Alexandru Croitor 2025-02-24 18:52:44 +01:00 committed by Qt Cherry-pick Bot
parent 2d38e0346c
commit ff32c71273
2 changed files with 16 additions and 8 deletions

View File

@ -53,11 +53,18 @@ function(_qt_internal_sbom_handle_qt_attribution_files out_prefix_outer)
math(EXPR attribution_file_count "${attribution_file_count} + 1")
endforeach()
# If CREATE_SBOM_FOR_EACH_ATTRIBUTION is set, that means the parent target was a qt entity,
# and not a 3rd party library.
# If CREATE_SBOM_FOR_EACH_ATTRIBUTION is set, that means the parent target is likely not a
# 3rd party library, so each attribution entry should create a separate attribution target.
# In which case we don't want to proagate options like CPE to the child attribution targets,
# because the CPE is meant for the parent target.
set(propagate_sbom_options_to_new_attribution_targets TRUE)
if(arg___QT_INTERNAL_HANDLE_QT_ENTITY_ATTRIBUTION_FILES)
_qt_internal_sbom_is_qt_entity_type("${arg_TYPE}" is_qt_entity_type)
if(is_qt_entity_type)
set(arg_CREATE_SBOM_FOR_EACH_ATTRIBUTION TRUE)
endif()
endif()
if(arg_CREATE_SBOM_FOR_EACH_ATTRIBUTION)
set(propagate_sbom_options_to_new_attribution_targets FALSE)
if(NOT arg_ATTRIBUTION_PARENT_TARGET)
@ -249,9 +256,15 @@ function(_qt_internal_sbom_handle_qt_attribution_files out_prefix_outer)
# Create another sbom target with the id as a hint for the target name,
# the attribution file passed, and make the new target a dependency of the
# parent one.
if(arg___QT_INTERNAL_HANDLE_QT_ENTITY_ATTRIBUTION_FILES)
set(attribution_entity_type QT_THIRD_PARTY_SOURCES)
else()
set(attribution_entity_type THIRD_PARTY_SOURCES)
endif()
_qt_internal_add_sbom("${attribution_target}"
IMMEDIATE_FINALIZATION
TYPE QT_THIRD_PARTY_SOURCES
TYPE "${attribution_entity_type}"
ATTRIBUTION_FILE_PATHS "${attribution_file_path}"
ATTRIBUTION_ENTRY_INDEX "${entry_index}"
NO_CURRENT_DIR_ATTRIBUTION

View File

@ -654,7 +654,6 @@ function(_qt_internal_sbom_add_target target)
set(project_package_options "")
_qt_internal_sbom_is_qt_entity_type("${arg_TYPE}" is_qt_entity_type)
_qt_internal_sbom_is_qt_3rd_party_entity_type("${arg_TYPE}" is_qt_3rd_party_entity_type)
if(arg_FRIENDLY_PACKAGE_NAME)
set(package_name_for_spdx_id "${arg_FRIENDLY_PACKAGE_NAME}")
@ -699,10 +698,6 @@ function(_qt_internal_sbom_add_target target)
ATTRIBUTION_PARENT_TARGET "${target}"
)
if(is_qt_entity_type AND arg___QT_INTERNAL_HANDLE_QT_ENTITY_ATTRIBUTION_FILES)
list(APPEND attribution_args CREATE_SBOM_FOR_EACH_ATTRIBUTION)
endif()
# Forward the sbom specific options when handling attribution files because those might
# create other sbom targets that need to inherit the parent ones.
_qt_internal_get_sbom_specific_options(sbom_opt_args sbom_single_args sbom_multi_args)