CMake: Deploy correct arch files when cross-compiling to arm Windows

When cross-compiling a user project from x86_64 to arm64 MSVC Windows
target, during deployment we need to deploy arm libraries.

By default because we use an x86_64 windeployqt, it always deploys
x86_64 libraries.

Make sure to pass the path to the target WoA qtpaths.bat file to
windeployqt, so it deploys arm libraries.

Pick-to: 6.5
Fixes: QTBUG-119619
Change-Id: Ib3b5498ae906726d1f9e0919333c102898b48ea9
Reviewed-by: 🌴 Alexey Edelev 🌴 <alexey.edelev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
(cherry picked from commit 571201603acc731330c9af42a3aca9cda41d38fd)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 01d12a2d98c5bcda5b15d2ebfe6d32b872e8f6e6)
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Alexandru Croitor 2023-12-14 17:23:38 +01:00
parent 3d53016d1b
commit f04bf38d54
2 changed files with 22 additions and 0 deletions

View File

@ -403,6 +403,13 @@ function(qt6_deploy_runtime_dependencies)
if(arg_NO_COMPILER_RUNTIME)
list(APPEND tool_options --no-compiler-runtime)
endif()
# Specify path to target Qt's qtpaths .exe or .bat file, so windeployqt deploys the correct
# libraries when cross-compiling from x86_64 to arm64 windows.
if(__QT_DEPLOY_TARGET_QT_PATHS_PATH)
list(APPEND tool_options --qtpaths "${__QT_DEPLOY_TARGET_QT_PATHS_PATH}")
endif()
elseif(__QT_DEPLOY_SYSTEM_NAME STREQUAL Darwin)
set(extra_binaries_option "-executable=")
if(NOT arg_NO_APP_STORE_COMPLIANCE)

View File

@ -2661,6 +2661,20 @@ function(_qt_internal_setup_deploy_support)
endif()
endif()
# Generate path to the target (not host) qtpaths file. Needed for windeployqt when
# cross-compiling from an x86_64 host to an arm64 target, so it knows which architecture
# libraries should be deployed.
if(CMAKE_HOST_WIN32)
if(CMAKE_CROSSCOMPILING)
set(qt_paths_ext ".bat")
else()
set(qt_paths_ext ".exe")
endif()
else()
set(qt_paths_ext "")
endif()
set(target_qtpaths_path "${QT6_INSTALL_PREFIX}/${QT6_INSTALL_BINS}/qtpaths${qt_paths_ext}")
file(GENERATE OUTPUT "${QT_DEPLOY_SUPPORT}" CONTENT
"cmake_minimum_required(VERSION 3.16...3.21)
@ -2707,6 +2721,7 @@ set(__QT_DEPLOY_QT_INSTALL_PREFIX \"${QT6_INSTALL_PREFIX}\")
set(__QT_DEPLOY_QT_INSTALL_BINS \"${QT6_INSTALL_BINS}\")
set(__QT_DEPLOY_QT_INSTALL_PLUGINS \"${QT6_INSTALL_PLUGINS}\")
set(__QT_DEPLOY_QT_INSTALL_TRANSLATIONS \"${QT6_INSTALL_TRANSLATIONS}\")
set(__QT_DEPLOY_TARGET_QT_PATHS_PATH \"${target_qtpaths_path}\")
set(__QT_DEPLOY_PLUGINS \"\")
set(__QT_DEPLOY_MUST_ADJUST_PLUGINS_RPATH \"${must_adjust_plugins_rpath}\")
set(__QT_DEPLOY_USE_PATCHELF \"${QT_DEPLOY_USE_PATCHELF}\")