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 6.9
Change-Id: I386fc9c09276c49207382b06605efeb0d939b6da
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
Alexandru Croitor 2025-03-18 19:33:20 +01:00
parent 11b54b85ce
commit 3c80dd518a

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