diff options
| author | Alexandru Croitor <[email protected]> | 2021-09-27 12:27:23 +0200 |
|---|---|---|
| committer | Alexandru Croitor <[email protected]> | 2021-09-27 18:29:44 +0200 |
| commit | 2ed267c82015f5eab7fe65aad6553eb0d6bb338d (patch) | |
| tree | 8ee77579e5865282657cd171c8f188f3d2241331 | |
| parent | 5d840f0f7a575a5163800519d7ef7d4ba228135a (diff) | |
CMake: Show error in user projects if wasm toolchain file not found
Rather than fail with obscure can't find Qt packages errors when the
Webassembly CMake toolchain file can not be found, error out with a
clear error on how to ensure it is found.
Pick-to: 6.2
Task-number: QTBUG-96843
Change-Id: I0f34cdcde05efb25c93017f3fd365186335ed52c
Reviewed-by: Joerg Bornemann <[email protected]>
| -rw-r--r-- | cmake/QtAutoDetect.cmake | 6 | ||||
| -rw-r--r-- | cmake/QtPublicWasmToolchainHelpers.cmake | 16 | ||||
| -rw-r--r-- | cmake/QtToolchainHelpers.cmake | 11 | ||||
| -rw-r--r-- | cmake/qt.toolchain.cmake.in | 3 |
4 files changed, 31 insertions, 5 deletions
diff --git a/cmake/QtAutoDetect.cmake b/cmake/QtAutoDetect.cmake index ba25377abeb..128a882b8dd 100644 --- a/cmake/QtAutoDetect.cmake +++ b/cmake/QtAutoDetect.cmake @@ -43,11 +43,7 @@ function(qt_auto_detect_wasm) message(STATUS "Emscripten ${EMCC_VERSION} toolchain file detected at ${CMAKE_TOOLCHAIN_FILE}") else() - message(FATAL_ERROR - "Cannot find the toolchain file Emscripten.cmake. " - "Please specify the toolchain file with -DCMAKE_TOOLCHAIN_FILE=<file> " - "or provide a path to a valid emscripten installation via the EMSDK " - "environment variable.") + __qt_internal_show_error_no_emscripten_toolchain_file_found_when_building_qt() endif() qt_internal_ensure_static_qt_config() diff --git a/cmake/QtPublicWasmToolchainHelpers.cmake b/cmake/QtPublicWasmToolchainHelpers.cmake index 53d74e0234c..8d0d9efdc95 100644 --- a/cmake/QtPublicWasmToolchainHelpers.cmake +++ b/cmake/QtPublicWasmToolchainHelpers.cmake @@ -53,3 +53,19 @@ function(__qt_internal_get_emcc_recommended_version out_var) set(QT_EMCC_RECOMMENDED_VERSION "2.0.14") set(${out_var} "${QT_EMCC_RECOMMENDED_VERSION}" PARENT_SCOPE) endfunction() + +function(__qt_internal_show_error_no_emscripten_toolchain_file_found_when_building_qt) + message(FATAL_ERROR + "Cannot find the toolchain file Emscripten.cmake. " + "Please specify the toolchain file with -DCMAKE_TOOLCHAIN_FILE=<file> " + "or provide a path to a valid emscripten installation via the EMSDK " + "environment variable.") +endfunction() + +function(__qt_internal_show_error_no_emscripten_toolchain_file_found_when_using_qt) + message(FATAL_ERROR + "Cannot find the toolchain file Emscripten.cmake. " + "Please specify the toolchain file with -DQT_CHAINLOAD_TOOLCHAIN_FILE=<file> " + "or provide a path to a valid emscripten installation via the EMSDK " + "environment variable.") +endfunction() diff --git a/cmake/QtToolchainHelpers.cmake b/cmake/QtToolchainHelpers.cmake index 863a3af8c3c..e7bf2eda562 100644 --- a/cmake/QtToolchainHelpers.cmake +++ b/cmake/QtToolchainHelpers.cmake @@ -236,13 +236,24 @@ if(DEFINED ENV{EMSDK} AND NOT \"\$ENV{EMSDK}\" STREQUAL \"\") set(__qt_chainload_toolchain_file \"\${_qt_candidate_emscripten_toolchain_path}\") endif() ") + list(APPEND init_post_chainload_toolchain " +if(NOT __qt_chainload_toolchain_file_included) + __qt_internal_show_error_no_emscripten_toolchain_file_found_when_using_qt() +endif() +") endif() string(REPLACE ";" "\n" init_additional_used_variables "${init_additional_used_variables}") string(REPLACE ";" "\n" init_vcpkg "${init_vcpkg}") + string(REPLACE ";" "\n" init_platform "${init_platform}") string(REPLACE "LITERAL_SEMICOLON" ";" init_platform "${init_platform}") + + string(REPLACE ";" "\n" init_post_chainload_toolchain "${init_post_chainload_toolchain}") + string(REPLACE "LITERAL_SEMICOLON" ";" init_post_chainload_toolchain + "${init_post_chainload_toolchain}") + qt_compute_relative_path_from_cmake_config_dir_to_prefix() configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/qt.toolchain.cmake.in" diff --git a/cmake/qt.toolchain.cmake.in b/cmake/qt.toolchain.cmake.in index 9a8019a3da4..38a7431620d 100644 --- a/cmake/qt.toolchain.cmake.in +++ b/cmake/qt.toolchain.cmake.in @@ -43,10 +43,13 @@ if(__qt_chainload_toolchain_file) "'${__qt_chainload_toolchain_file}' does not exist.") else() include("${__qt_chainload_toolchain_file}") + set(__qt_chainload_toolchain_file_included TRUE) endif() unset(__qt_chainload_toolchain_file) endif() +@init_post_chainload_toolchain@ + # Compute dynamically the Qt installation prefix from the location of this file. This allows # the usage of the toolchain file when the Qt installation is relocated. get_filename_component(QT_TOOLCHAIN_RELOCATABLE_INSTALL_PREFIX |
