From 3bd54f285dd41f4c176ed54161b58ab5c85e14c3 Mon Sep 17 00:00:00 2001 From: David Skoland Date: Thu, 8 Sep 2022 07:32:38 +0200 Subject: [PATCH] wasm: Replace QT6_INSTALL_PREFIX with WASM_BUILD_DIR in cmake helper The change b515fa56a3144289023dc9588c5f73283599e4d4 introduced checking the emsdk version of a qt installation. However, this checked for QT6_INSTALL_PREFIX where it may not be defined. This fails when trying to build tests because when configuring tests, it calls into add_target_helpers which calls into this logic, and QT6_INSTALL_PREFIX is set after this is called into, causing the qconfig.h lookup to fail. To fix this so it works in all conditions, we need to check if either install prefix or build_dir is set and use whichever is set. Pick-to: 6.4 Change-Id: I3cf7e20d3d830f04e5b632fc51d8bf3b2758a717 Reviewed-by: Alexandru Croitor --- cmake/QtPublicWasmToolchainHelpers.cmake | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cmake/QtPublicWasmToolchainHelpers.cmake b/cmake/QtPublicWasmToolchainHelpers.cmake index 433b29a9def..3ad94248486 100644 --- a/cmake/QtPublicWasmToolchainHelpers.cmake +++ b/cmake/QtPublicWasmToolchainHelpers.cmake @@ -74,10 +74,15 @@ function(__qt_internal_show_error_no_emscripten_toolchain_file_found_when_using_ endfunction() function(__qt_internal_get_qt_build_emsdk_version out_var) - if(EXISTS "${QT6_INSTALL_PREFIX}/src/corelib/global/qconfig.h") - file(READ "${QT6_INSTALL_PREFIX}/src/corelib/global/qconfig.h" ver) + if(QT6_INSTALL_PREFIX) + set(WASM_BUILD_DIR "${QT6_INSTALL_PREFIX}") + elseif(QT_BUILD_DIR) + set(WASM_BUILD_DIR "${QT_BUILD_DIR}") + endif() + if(EXISTS "${WASM_BUILD_DIR}/src/corelib/global/qconfig.h") + file(READ "${WASM_BUILD_DIR}/src/corelib/global/qconfig.h" ver) else() - file(READ "${QT6_INSTALL_PREFIX}/include/QtCore/qconfig.h" ver) + file(READ "${WASM_BUILD_DIR}/include/QtCore/qconfig.h" ver) endif() string(REGEX MATCH "#define QT_EMCC_VERSION.\"[0-9]+\\.[0-9]+\\.[0-9]+\"" emOutput ${ver}) string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" build_emcc_version "${emOutput}")