diff options
author | Alexandru Croitor <[email protected]> | 2025-05-26 15:54:25 +0200 |
---|---|---|
committer | Alexandru Croitor <[email protected]> | 2025-05-26 20:11:33 +0200 |
commit | d2ed84514d935aea412b6944866aeb41aa97ea89 (patch) | |
tree | 96e3658c4c98a5d1040939d95f6448756d5af88b /cmake | |
parent | fcb89d156089c5b0f6d54bb2606c5bdd50081c22 (diff) |
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 6.9
Fixes: QTBUG-137168
Change-Id: I970c3bc5732cc648549e5099fa1d50b3b39cb26f
Reviewed-by: Alexey Edelev <[email protected]>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/QtBuildRepoHelpers.cmake | 7 | ||||
-rw-r--r-- | cmake/QtPublicSbomFileHelpers.cmake | 4 |
2 files changed, 9 insertions, 2 deletions
diff --git a/cmake/QtBuildRepoHelpers.cmake b/cmake/QtBuildRepoHelpers.cmake index fc8945d4c9c..bca25233365 100644 --- a/cmake/QtBuildRepoHelpers.cmake +++ b/cmake/QtBuildRepoHelpers.cmake @@ -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) diff --git a/cmake/QtPublicSbomFileHelpers.cmake b/cmake/QtPublicSbomFileHelpers.cmake index 3a06a670b31..1b2abc91af0 100644 --- a/cmake/QtPublicSbomFileHelpers.cmake +++ b/cmake/QtPublicSbomFileHelpers.cmake @@ -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() |