From d24936dbdc85d5fe875b5d3df702630df4d4ba9d Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Fri, 12 Jul 2024 11:22:49 +0200 Subject: [PATCH] CMake: Fix SBOM unsupported type for internal apps targeting Android Usually apps created by qt_internal_add_app() are not meant for installation on Android, and are excluded from installation using qt_exclude_tool_directories_from_default_target(). Some repos might be missing the exclusion call, which means the app would be built and installed on Android. qt_internal_add_app creates MODULE_LIBRARYs instead of EXECUTABLEs when targeting Android. While the SBOM machinery only expects EXECUTABLEs for apps. If the app target is not excluded (in which case the SBOM would be skipped), this would cause the SBOM code to error out saying the target type is unsupported. To prevent further errors like this, add MODULE_LIBRARY as a valid target type for qt apps. Pick-to: 6.8 Task-number: QTBUG-122899 Change-Id: I3ec80add22f0584638990171c59b78c24725c052 Reviewed-by: Alexey Edelev --- cmake/QtPublicSbomHelpers.cmake | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cmake/QtPublicSbomHelpers.cmake b/cmake/QtPublicSbomHelpers.cmake index 8dfec929999..b6502f0bb18 100644 --- a/cmake/QtPublicSbomHelpers.cmake +++ b/cmake/QtPublicSbomHelpers.cmake @@ -1135,7 +1135,14 @@ function(_qt_internal_sbom_handle_target_binary_files target) if(arg_TYPE STREQUAL "QT_TOOL" OR arg_TYPE STREQUAL "QT_APP" OR arg_TYPE STREQUAL "EXECUTABLE") - if(NOT target_type STREQUAL "EXECUTABLE") + + set(valid_executable_types + "EXECUTABLE" + ) + if(ANDROID) + list(APPEND valid_executable_types "MODULE_LIBRARY") + endif() + if(NOT target_type IN_LIST valid_executable_types) message(FATAL_ERROR "Unsupported target type: ${target_type}") endif()