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 <alexandru.croitor@qt.io>
This commit is contained in:
David Skoland 2022-09-08 07:32:38 +02:00
parent 701852e17b
commit 3bd54f285d

View File

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