diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2021-09-27 12:27:23 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-09-27 16:30:19 +0000 |
commit | edb8087fcae4400b6405f65b076703d28f2309c9 (patch) | |
tree | beb04f3979ab9c20e2934dfdb5f112f34e382c53 /cmake | |
parent | ad4ae48c8e1501a0585b1a4565807a6a17cbc4d5 (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.
Task-number: QTBUG-96843
Change-Id: I0f34cdcde05efb25c93017f3fd365186335ed52c
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit 2ed267c82015f5eab7fe65aad6553eb0d6bb338d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'cmake')
-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 ba25377abe..128a882b8d 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 53d74e0234..8d0d9efdc9 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 ce5d7a3fd8..b10b571ce3 100644 --- a/cmake/QtToolchainHelpers.cmake +++ b/cmake/QtToolchainHelpers.cmake @@ -235,13 +235,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 9a8019a3da..38a7431620 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 |