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= " - "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= " + "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= " + "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 ce5d7a3fd8d..b10b571ce37 100644 --- a/cmake/QtToolchainHelpers.cmake +++ b/cmake/QtToolchainHelpers.cmake @@ -234,14 +234,25 @@ if(DEFINED ENV{EMSDK} AND NOT \"\$ENV{EMSDK}\" STREQUAL \"\") \"\${__qt_toolchain_emroot_path}\" _qt_candidate_emscripten_toolchain_path) 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