summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2021-09-24 17:06:02 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-09-27 16:30:04 +0000
commitad4ae48c8e1501a0585b1a4565807a6a17cbc4d5 (patch)
tree30eb9451b39927b93b8d9928d77f3dab3af12bc7 /cmake
parent7355f3647167d08d252296f59d322b528323e879 (diff)
CMake: Get toolchain file path from EMSDK env for Wasm user projects
Try to to chainload the emscripten CMake toolchain file from the EMSDK env var if it is set, instead of requiring the user to explicitly specify a path to the file via QT_CHAINLOAD_TOOLCHAIN_FILE. The order in which the toolchain file is chainloaded becomes is as follows: 1) The initial toolchain file path that was specified when configuring qtbase is set written as the initial value of __qt_chainload_toolchain_file in qt.toolchain.cmake 2) If EMSDK env var is set, it overrides the value from 1) 3) If QT_CHAINLOAD_TOOLCHAIN_FILE cache var is supplied it overrides the value from 2) Whichever value ends up in __qt_chainload_toolchain_file is checked too see if the file exists. If it exists it gets included, if it doesn't, a warning is issued. This checking logic is a bit crude and should be improved and unified with the Android chainload checking, but the current change already improves the behavior for users of Qt. Task-number: QTBUG-96843 Change-Id: I5da58a329f659086aaaee765c9399d0369021b22 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 5d840f0f7a575a5163800519d7ef7d4ba228135a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtAutoDetect.cmake4
-rw-r--r--cmake/QtToolchainHelpers.cmake15
2 files changed, 18 insertions, 1 deletions
diff --git a/cmake/QtAutoDetect.cmake b/cmake/QtAutoDetect.cmake
index efb798f3c4..ba25377abe 100644
--- a/cmake/QtAutoDetect.cmake
+++ b/cmake/QtAutoDetect.cmake
@@ -56,6 +56,10 @@ function(qt_auto_detect_wasm)
set(QT_EMCC_RECOMMENDED_VERSION "${recommended_version}" CACHE STRING INTERNAL FORCE)
set(QT_AUTODETECT_WASM_IS_DONE TRUE CACHE BOOL "")
+ else()
+ message(STATUS
+ "Reusing cached Emscripten ${EMCC_VERSION} toolchain file detected at "
+ "${CMAKE_TOOLCHAIN_FILE}")
endif()
endif()
endfunction()
diff --git a/cmake/QtToolchainHelpers.cmake b/cmake/QtToolchainHelpers.cmake
index 4b0af30f1a..ce5d7a3fd8 100644
--- a/cmake/QtToolchainHelpers.cmake
+++ b/cmake/QtToolchainHelpers.cmake
@@ -33,7 +33,10 @@ function(qt_internal_create_toolchain_file)
if(CMAKE_TOOLCHAIN_FILE)
file(TO_CMAKE_PATH "${CMAKE_TOOLCHAIN_FILE}" __qt_chainload_toolchain_file)
set(init_original_toolchain_file
- "set(__qt_chainload_toolchain_file \"${__qt_chainload_toolchain_file}\")")
+ "
+set(__qt_initially_configured_toolchain_file \"${__qt_chainload_toolchain_file}\")
+set(__qt_chainload_toolchain_file \"\${__qt_initially_configured_toolchain_file}\")
+")
endif()
if(VCPKG_CHAINLOAD_TOOLCHAIN_FILE)
@@ -222,6 +225,16 @@ function(qt_internal_create_toolchain_file)
" \"Please specify the toolchain file with -DQT_CHAINLOAD_TOOLCHAIN_FILE=<file>.\")")
list(APPEND init_platform " endif()")
list(APPEND init_platform "endif()")
+ elseif(EMSCRIPTEN)
+ list(APPEND init_platform
+"include(\${CMAKE_CURRENT_LIST_DIR}/QtPublicWasmToolchainHelpers.cmake)
+if(DEFINED ENV{EMSDK} AND NOT \"\$ENV{EMSDK}\" STREQUAL \"\")
+ __qt_internal_get_emroot_path_suffix_from_emsdk_env(__qt_toolchain_emroot_path)
+ __qt_internal_get_emscripten_cmake_toolchain_file_path_from_emsdk_env(
+ \"\${__qt_toolchain_emroot_path}\" _qt_candidate_emscripten_toolchain_path)
+ set(__qt_chainload_toolchain_file \"\${_qt_candidate_emscripten_toolchain_path}\")
+endif()
+")
endif()
string(REPLACE ";" "\n" init_additional_used_variables