summaryrefslogtreecommitdiffstats
path: root/cmake/QtPublicWasmToolchainHelpers.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/QtPublicWasmToolchainHelpers.cmake')
-rw-r--r--cmake/QtPublicWasmToolchainHelpers.cmake41
1 files changed, 39 insertions, 2 deletions
diff --git a/cmake/QtPublicWasmToolchainHelpers.cmake b/cmake/QtPublicWasmToolchainHelpers.cmake
index 8d0d9efdc9..31f6b5aca5 100644
--- a/cmake/QtPublicWasmToolchainHelpers.cmake
+++ b/cmake/QtPublicWasmToolchainHelpers.cmake
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
# Assuming EMSDK == /path/emsdk
#
# Then we expect /path/emsdk/.emscripten file to contain the following line
@@ -27,7 +30,7 @@ function(__qt_internal_query_emsdk_version emroot_path is_fatal out_var)
set(EXECUTE_COMMANDPATH "$ENV{EMSDK}/${emroot_path}/emcc")
endif()
- file(TO_NATIVE_PATH "${EXECUTE_COMMANDPATH}" EXECUTE_COMMAND)
+ file(TO_CMAKE_PATH "${EXECUTE_COMMANDPATH}" EXECUTE_COMMAND)
execute_process(COMMAND ${EXECUTE_COMMAND} --version
OUTPUT_VARIABLE emOutput
OUTPUT_STRIP_TRAILING_WHITESPACE
@@ -50,7 +53,7 @@ endfunction()
function(__qt_internal_get_emcc_recommended_version out_var)
# This version of Qt needs this version of emscripten.
- set(QT_EMCC_RECOMMENDED_VERSION "2.0.14")
+ set(QT_EMCC_RECOMMENDED_VERSION "3.1.50")
set(${out_var} "${QT_EMCC_RECOMMENDED_VERSION}" PARENT_SCOPE)
endfunction()
@@ -69,3 +72,37 @@ function(__qt_internal_show_error_no_emscripten_toolchain_file_found_when_using_
"or provide a path to a valid emscripten installation via the EMSDK "
"environment variable.")
endfunction()
+
+function(__qt_internal_get_qt_build_emsdk_version out_var)
+ 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)
+ elseif(EXISTS "${WASM_BUILD_DIR}/include/QtCore/qconfig.h")
+ file(READ "${WASM_BUILD_DIR}/include/QtCore/qconfig.h" ver)
+ else()
+ message("qconfig.h not found, unable to determine Qt build Emscripten version")
+ endif()
+ if (ver)
+ 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}")
+ set(${out_var} "${build_emcc_version}" PARENT_SCOPE)
+ endif()
+endfunction()
+
+function(_qt_test_emscripten_version)
+ __qt_internal_get_emcc_recommended_version(_recommended_emver)
+ __qt_internal_get_emroot_path_suffix_from_emsdk_env(emroot_path)
+ __qt_internal_query_emsdk_version("${emroot_path}" TRUE current_emsdk_ver)
+ __qt_internal_get_qt_build_emsdk_version(qt_build_emcc_version)
+
+ if(NOT "${qt_build_emcc_version}" STREQUAL "${current_emsdk_ver}")
+ message("Qt Wasm built with Emscripten version: ${qt_build_emcc_version}")
+ message("You are using Emscripten version: ${current_emsdk_ver}")
+ message("The recommended version of Emscripten for this Qt is: ${_recommended_emver}")
+ message("This may not work correctly")
+ endif()
+endfunction()