From 71e490f0baee0d27a45a17886c48f5defbbaea42 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 5 Nov 2021 13:31:35 +0100 Subject: [PATCH] Provide a qtpaths wrapper script when cross-building Qt The qtpaths tool is supposed to replace "qmake -query", and it must be available for cross-builds as a wrapper script like qmake. Re-use the existing facility for creating the qmake wrapper script for creating the qtpaths wrapper script. Pick-to: 6.2 Fixes: QTBUG-97821 Change-Id: I460bae61a531994422e1c0fba09c79e4aa65713f Reviewed-by: Alexandru Croitor --- bin/qmake-and-qtpaths-wrapper.bat.in | 2 + ...target.in => qmake-and-qtpaths-wrapper.in} | 2 +- bin/qmake-wrapper-for-target.bat.in | 2 - cmake/QtBaseGlobalTargets.cmake | 2 +- cmake/QtQmakeHelpers.cmake | 44 ++++++++++--------- 5 files changed, 27 insertions(+), 25 deletions(-) create mode 100644 bin/qmake-and-qtpaths-wrapper.bat.in rename bin/{qmake-wrapper-for-target.in => qmake-and-qtpaths-wrapper.in} (71%) mode change 100644 => 100755 delete mode 100644 bin/qmake-wrapper-for-target.bat.in diff --git a/bin/qmake-and-qtpaths-wrapper.bat.in b/bin/qmake-and-qtpaths-wrapper.bat.in new file mode 100644 index 00000000000..8225170fc9d --- /dev/null +++ b/bin/qmake-and-qtpaths-wrapper.bat.in @@ -0,0 +1,2 @@ +@echo off +@host_qt_bindir@\@tool_name@.exe -qtconf "%~dp0\target_qt.conf" %* diff --git a/bin/qmake-wrapper-for-target.in b/bin/qmake-and-qtpaths-wrapper.in old mode 100644 new mode 100755 similarity index 71% rename from bin/qmake-wrapper-for-target.in rename to bin/qmake-and-qtpaths-wrapper.in index 265ce760de3..f26355af8d9 --- a/bin/qmake-wrapper-for-target.in +++ b/bin/qmake-and-qtpaths-wrapper.in @@ -4,4 +4,4 @@ script_dir_path=`dirname $0` script_dir_path=`(cd "$script_dir_path"; /bin/pwd)` -@host_qt_bindir@/qmake -qtconf "$script_dir_path/target_qt.conf" $* +@host_qt_bindir@/@tool_name@ -qtconf "$script_dir_path/target_qt.conf" $* diff --git a/bin/qmake-wrapper-for-target.bat.in b/bin/qmake-wrapper-for-target.bat.in deleted file mode 100644 index 8df27eaa443..00000000000 --- a/bin/qmake-wrapper-for-target.bat.in +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -@host_qt_bindir@\qmake.exe -qtconf "%~dp0\target_qt.conf" %* diff --git a/cmake/QtBaseGlobalTargets.cmake b/cmake/QtBaseGlobalTargets.cmake index 38fe49f6d6c..bddc597bdbe 100644 --- a/cmake/QtBaseGlobalTargets.cmake +++ b/cmake/QtBaseGlobalTargets.cmake @@ -110,7 +110,7 @@ qt_feature_module_end(GlobalConfig OUT_VAR_PREFIX "__GlobalConfig_") qt_generate_global_config_pri_file() qt_generate_global_module_pri_file() qt_generate_global_device_pri_file() -qt_generate_qmake_wrapper_for_target() +qt_generate_qmake_and_qtpaths_wrapper_for_target() add_library(Qt::GlobalConfig ALIAS GlobalConfig) diff --git a/cmake/QtQmakeHelpers.cmake b/cmake/QtQmakeHelpers.cmake index 3fb126344db..668702f968a 100644 --- a/cmake/QtQmakeHelpers.cmake +++ b/cmake/QtQmakeHelpers.cmake @@ -68,10 +68,10 @@ function(qt_generate_qconfig_cpp in_file out_file) endfunction() # In the cross-compiling case, creates a wrapper around the host Qt's -# qmake executable. Also creates a qmake configuration file that sets +# qmake and qtpaths executables. Also creates a qmake configuration file that sets # up the host qmake's properties for cross-compiling with this Qt # build. -function(qt_generate_qmake_wrapper_for_target) +function(qt_generate_qmake_and_qtpaths_wrapper_for_target) if(NOT CMAKE_CROSSCOMPILING) return() endif() @@ -127,27 +127,29 @@ TargetSpec=${QT_QMAKE_TARGET_MKSPEC} HostSpec=${QT_QMAKE_HOST_MKSPEC} ") file(GENERATE OUTPUT "${qt_conf_path}" CONTENT "${content}") - - qt_path_join(qmake_wrapper_in_file "${CMAKE_CURRENT_SOURCE_DIR}/bin/qmake-wrapper-for-target") - set(qmake_wrapper "qmake") - if(QT_BUILD_TOOLS_WHEN_CROSSCOMPILING) - # Avoid collisions with the cross-compiled qmake binary. - string(PREPEND qmake_wrapper "host-") - endif() - if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") - string(APPEND qmake_wrapper_in_file ".bat") - string(APPEND qmake_wrapper ".bat") - endif() - string(APPEND qmake_wrapper_in_file ".in") - - set(host_qt_bindir "${host_prefix}/${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_BINDIR}") - qt_path_join(qmake_wrapper "preliminary" "${qmake_wrapper}") - - configure_file("${qmake_wrapper_in_file}" "${qmake_wrapper}" @ONLY) qt_install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${qt_conf_path}" DESTINATION "${INSTALL_BINDIR}") - qt_copy_or_install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/${qmake_wrapper}" - DESTINATION "${INSTALL_BINDIR}") + + set(wrapper_prefix) + set(wrapper_extension) + if(QT_BUILD_TOOLS_WHEN_CROSSCOMPILING) + # Avoid collisions with the cross-compiled qmake/qtpaths binaries. + set(wrapper_prefix "host-") + endif() + if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") + set(wrapper_extension ".bat") + endif() + + set(wrapper_in_file + "${CMAKE_CURRENT_SOURCE_DIR}/bin/qmake-and-qtpaths-wrapper${wrapper_extension}.in") + set(host_qt_bindir "${host_prefix}/${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_BINDIR}") + + foreach(tool_name qmake qtpaths) + set(wrapper "preliminary/${wrapper_prefix}${tool_name}${wrapper_extension}") + configure_file("${wrapper_in_file}" "${wrapper}" @ONLY) + qt_copy_or_install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/${wrapper}" + DESTINATION "${INSTALL_BINDIR}") + endforeach() endfunction() # Transforms a CMake Qt module name to a qmake Qt module name.