From 1dc962cbe0ed0e10bd3c947b77db86350eb10d1a Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Tue, 18 Mar 2025 19:33:20 +0100 Subject: [PATCH] CMake: Clean up leftover attribution values during SBOM generation When processing multiple attribution files to collect all attribution ids, the values of the previous iteration extracted keys were not reset. This caused the values to leak to the next processed attribution id target if the specific id key was empty. Make sure to clean up the values before parsing the next attribution key. Pick-to: 6.8 Change-Id: I386fc9c09276c49207382b06605efeb0d939b6da Reviewed-by: Alexey Edelev (cherry picked from commit 3c80dd518a3bdc5f2c4df64c5330678294e06eb7) Reviewed-by: Qt Cherry-pick Bot --- cmake/QtPublicSbomAttributionHelpers.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/QtPublicSbomAttributionHelpers.cmake b/cmake/QtPublicSbomAttributionHelpers.cmake index 22e80b464e0..2d25fcd0b39 100644 --- a/cmake/QtPublicSbomAttributionHelpers.cmake +++ b/cmake/QtPublicSbomAttributionHelpers.cmake @@ -524,6 +524,9 @@ endfunction() macro(_qt_internal_sbom_get_attribution_key json_key out_var out_prefix) cmake_parse_arguments(arg "IS_MULTI_VALUE" "" "" ${ARGN}) + # Reset any leftover value that might have been set in a previous iteration. + set(${out_prefix}_${out_var} "" PARENT_SCOPE) + string(JSON "${out_var}" ERROR_VARIABLE get_error GET "${contents}" ${indices} "${json_key}") if(NOT "${${out_var}}" STREQUAL "" AND NOT get_error) set(extracted_value "${${out_var}}")