CMake: Extract Qt-specific license concluded handling

Extract the handling of the license concluded expression for Qt
entities into the Qt specific handling file.

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: Ib6f9a64f66dae0c971c43e8fffbc54362487b271
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Alexandru Croitor 2025-02-24 19:02:16 +01:00
parent 0d9106bf76
commit ba93956be1
2 changed files with 32 additions and 5 deletions

View File

@ -653,8 +653,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)
if(arg_FRIENDLY_PACKAGE_NAME)
set(package_name_for_spdx_id "${arg_FRIENDLY_PACKAGE_NAME}")
else()
@ -763,10 +761,18 @@ function(_qt_internal_sbom_add_target target)
if(license_expression)
list(APPEND project_package_options LICENSE_CONCLUDED "${license_expression}")
endif()
# For qt entities we know the license we provide, so we mark it as declared as well.
if(arg___QT_INTERNAL_HANDLE_QT_ENTITY_TYPE_LICENSE AND is_qt_entity_type)
list(APPEND project_package_options LICENSE_DECLARED "${license_expression}")
if(license_expression AND
arg___QT_INTERNAL_HANDLE_QT_ENTITY_TYPE_LICENSE)
_qt_internal_sbom_forward_sbom_add_target_options(sbom_add_target_args)
_qt_internal_sbom_handle_qt_entity_license_declared_expression(${target}
${sbom_add_target_args}
LICENSE_CONCLUDED_EXPRESSION "${license_expression}"
OUT_VAR qt_entity_license_declared_expression)
if(qt_entity_license_declared_expression)
list(APPEND project_package_options
LICENSE_DECLARED "${qt_entity_license_declared_expression}")
endif()
endif()

View File

@ -154,6 +154,27 @@ function(_qt_internal_sbom_handle_qt_entity_license_expression target)
endif()
endfunction()
# Helper function to add a default license declared expression for a qt entity type.
function(_qt_internal_sbom_handle_qt_entity_license_declared_expression target)
_qt_internal_get_sbom_add_target_options(opt_args single_args multi_args)
list(APPEND single_args OUT_VAR LICENSE_CONCLUDED_EXPRESSION)
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
_qt_internal_sbom_is_qt_entity_type("${arg_TYPE}" is_qt_entity_type)
set(license_expression "")
# For qt entities we know the license we provide, so we mark it as declared as well.
if(is_qt_entity_type AND arg_LICENSE_CONCLUDED_EXPRESSION)
set(license_expression "${arg_LICENSE_CONCLUDED_EXPRESSION}")
endif()
if(license_expression)
set(${arg_OUT_VAR} "${license_expression}" PARENT_SCOPE)
endif()
endfunction()
# Get the default qt copyright.
function(_qt_internal_sbom_get_default_qt_copyright_header out_var)
set(${out_var}