CMake: Skip sbom file checksum checks for excluded test targets
If a developer configured Qt with -DQT_GENERATE_SBOM=ON -DQT_BUILD_TESTS=ON -DQT_BUILD_TESTS_BY_DEFAULT=OFF The would get the following error upon installation of qtmultimedia: CMake Error at qt_sbom/SPDXRef-PackagedFile-qt-plugin-MockMultimediaPlugin.cmake:5 (message): Cannot find 'plugins/multimedia/libmockmultimediaplugin.a' to compute its checksum. This happens because QT_BUILD_TESTS_BY_DEFAULT == ON sets the EXCLUDE_FROM_ALL directory property on the tests directory, which means all plugins created under tests/ subdir are not installed by default, and the SBOM code could not read the installed files to check the checksums. In such a case, set a QT_INTERNAL_TEST_TARGETS_EXCLUDE_FROM_ALL directory-scoped variable in the tests/ subdir, and use that as a marker for the sbom code to know it should skip the checksum check. Pick-to: 6.8 Fixes: QTBUG-137168 Change-Id: I970c3bc5732cc648549e5099fa1d50b3b39cb26f Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> (cherry picked from commit d2ed84514d935aea412b6944866aeb41aa97ea89) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
7837ffc57c
commit
af623abc58
@ -756,6 +756,13 @@ macro(qt_build_tests)
|
||||
# Indicates that we are configuring tests now
|
||||
set(QT_INTERNAL_CONFIGURING_TESTS TRUE)
|
||||
|
||||
# Set this as a directory scoped variable, so we can easily check the variable in child
|
||||
# directories, to prevent certain code from running, like sbom file checks for all targets
|
||||
# created in tests subdir.
|
||||
if(NOT QT_BUILD_TESTS_BY_DEFAULT)
|
||||
set(QT_INTERNAL_TEST_TARGETS_EXCLUDE_FROM_ALL TRUE)
|
||||
endif()
|
||||
|
||||
# Tests are not unity-ready.
|
||||
set(CMAKE_UNITY_BUILD OFF)
|
||||
|
||||
|
@ -93,8 +93,8 @@ function(_qt_internal_sbom_handle_target_binary_files target)
|
||||
return()
|
||||
endif()
|
||||
|
||||
get_target_property(excluded ${target} _qt_internal_excluded_from_default_target)
|
||||
if(excluded)
|
||||
get_target_property(excluded_via_property ${target} _qt_internal_excluded_from_default_target)
|
||||
if(excluded_via_property OR QT_INTERNAL_TEST_TARGETS_EXCLUDE_FROM_ALL)
|
||||
message(DEBUG "Target ${target} has no binary files to reference in the SBOM "
|
||||
"because it was excluded from the default 'all' target.")
|
||||
return()
|
||||
|
Loading…
x
Reference in New Issue
Block a user