From 8113dc73f07522fd7f54a84517bd7d2f6e0268aa Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Thu, 17 Oct 2024 20:40:18 +0200 Subject: [PATCH] CMake: Fix DESTDIR handling in SBOM checksum verification The DESTDIR env var needs to be evaluated at install time, not configure time, so the $ENV{} needs to be escaped in the generated script. Also improve the error message a bit, to say which path exactly it expected to read. This fixes SBOM generation for the debian package builds. Task-number: QTBUG-122899 Change-Id: I6869f0054601dcb35ae7ad7b55f808df4dc12311 Reviewed-by: Joerg Bornemann (cherry picked from commit 08d5d9e9da8a4815be7dd2c952cb45a6597cc077) Reviewed-by: Qt Cherry-pick Bot --- cmake/QtPublicSbomGenerationHelpers.cmake | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cmake/QtPublicSbomGenerationHelpers.cmake b/cmake/QtPublicSbomGenerationHelpers.cmake index 10d84fa1647..802cef52b89 100644 --- a/cmake/QtPublicSbomGenerationHelpers.cmake +++ b/cmake/QtPublicSbomGenerationHelpers.cmake @@ -596,17 +596,18 @@ FileCopyrightText: NOASSERTION" endif() set(content " - if(NOT EXISTS $ENV{DESTDIR}${install_prefix}/${arg_FILENAME} + if(NOT EXISTS \$ENV{DESTDIR}${install_prefix}/${arg_FILENAME} AND NOT QT_SBOM_BUILD_TIME AND NOT QT_SBOM_FAKE_CHECKSUM) if(NOT ${arg_OPTIONAL}) - message(FATAL_ERROR \"Cannot find ${arg_FILENAME}\") + message(FATAL_ERROR \"Cannot find '${arg_FILENAME}' to compute its checksum. \" + \"Expected to find it at '\$ENV{DESTDIR}${install_prefix}/${arg_FILENAME}' \") endif() else() if(NOT QT_SBOM_BUILD_TIME) if(QT_SBOM_FAKE_CHECKSUM) set(sha1 \"158942a783ee1095eafacaffd93de73edeadbeef\") else() - file(SHA1 $ENV{DESTDIR}${install_prefix}/${arg_FILENAME} sha1) + file(SHA1 \$ENV{DESTDIR}${install_prefix}/${arg_FILENAME} sha1) endif() list(APPEND QT_SBOM_VERIFICATION_CODES \${sha1}) endif()