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 <alexey.edelev@qt.io>
(cherry picked from commit 3c80dd518a3bdc5f2c4df64c5330678294e06eb7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Alexandru Croitor 2025-03-18 19:33:20 +01:00 committed by Qt Cherry-pick Bot
parent 7537bfbadf
commit 1dc962cbe0

View File

@ -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}}")