Change the -qpa configure argument logic

Parse the -qpa configure argument as list and translate it to the
QT_QPA_PLATFORMS cmake variable. This variable is new to the Qt build
procedure. The QT_QPA_DEFAULT_PLATFORM variable supposed to get
multiple values, but this didn't work at all, since the variable value
then was used in the compile definition that is expected to be a single
value QPA platfrom definition. This inconsistency forced to introduce
a new variable.

The QT_QPA_DEFAULT_PLATFORM variable now controls the first-choice QPA
plugin for the GUI applications. The new configure argument
-default-qpa is now translated to the QT_QPA_DEFAULT_PLATFORM variable
instead the of -qpa one. The -qpa configure argument is now translated
to the QT_QPA_PLATFORMS variable, which is new one as well. The
variable contains the list of QPA plugins that are "default" for this
Qt configuration. The meaning of the "default" plugins is related to
the DEFAULT_IF argument of qt_internal_add_plugin command. Plugins
that are listed in the QT_QPA_PLATFORMS variable will be treated as
default by the build system and will be deployed within user
applications when using deployment API or linked statically when using
static Qt.

The QT_QPA_DEFAULT_PLATFORM falls back to the QT_QPA_PLATFORMS first
value in the list if it's not set explicitly and either
'-DQT_QPA_PLATFORMS' or '-qpa' arguments are specified.

[ChangeLog][CMake] Added QT_QPA_PLATFORMS variable which controls the
list of QPA plugins that will be deployed within the applications by
default.
[ChangeLog][CMake] The '-qpa' configure argument now is mapped to the
QT_QPA_PLATFORMS variable and has different functionality. It doesn't
control the platform plugin that the GUI application is using by
default, but controls the list of QPA plugins that will be deployed
within the applications by default.
[ChangeLog][CMake] Added '-default-qpa' argument which replaces the
'-qpa' one. The argument is translated to the QT_DEFAULT_QPA_PLATFORM
CMake variable and selects the default platform that should be used
by GUI application if QT_QPA_PLATFORM environment variable is not set.

Task-number: QTBUG-124265
Task-number: QTBUG-87805
Task-number: QTBUG-124449
Change-Id: Ibcebaccc535aaed6374f15ccfeddb3e6128f5ce0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Alexey Edelev 2024-04-11 10:55:53 +02:00
parent e227a4bfbd
commit 90c2cde691
20 changed files with 39 additions and 21 deletions

View File

@ -653,13 +653,19 @@ set(__qt_internal_initial_qt_cmake_build_type \"${CMAKE_BUILD_TYPE}\")
endif() endif()
# Save the default qpa platform. # Save the default qpa platform.
# Used by qtwayland/src/plugins/platforms/qwayland-generic/CMakeLists.txt. Otherwise
# the DEFAULT_IF condition is evaluated incorrectly.
if(DEFINED QT_QPA_DEFAULT_PLATFORM) if(DEFINED QT_QPA_DEFAULT_PLATFORM)
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
"set(QT_QPA_DEFAULT_PLATFORM \"${QT_QPA_DEFAULT_PLATFORM}\" CACHE STRING \"\")\n") "set(QT_QPA_DEFAULT_PLATFORM \"${QT_QPA_DEFAULT_PLATFORM}\" CACHE STRING \"\")\n")
endif() endif()
# Save the list of default qpa platforms.
# Used by qtwayland/src/plugins/platforms/qwayland-generic/CMakeLists.txt. Otherwise
# the DEFAULT_IF condition is evaluated incorrectly.
if(DEFINED QT_QPA_PLATFORMS)
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
"set(QT_QPA_PLATFORMS \"${QT_QPA_PLATFORMS}\" CACHE STRING \"\")\n")
endif()
# Save minimum and policy-related CMake versions to ensure the same minimum is # Save minimum and policy-related CMake versions to ensure the same minimum is
# checked for when building other downstream repos (qtsvg, etc) and the policy settings # checked for when building other downstream repos (qtsvg, etc) and the policy settings
# will be consistent unless the downstream repos explicitly override them. # will be consistent unless the downstream repos explicitly override them.

View File

@ -943,6 +943,7 @@ translate_string_input(platform QT_QMAKE_TARGET_MKSPEC)
translate_string_input(xplatform QT_QMAKE_TARGET_MKSPEC) translate_string_input(xplatform QT_QMAKE_TARGET_MKSPEC)
guess_compiler_from_mkspec() guess_compiler_from_mkspec()
translate_string_input(qpa_default_platform QT_QPA_DEFAULT_PLATFORM) translate_string_input(qpa_default_platform QT_QPA_DEFAULT_PLATFORM)
translate_list_input(qpa_platforms QT_QPA_PLATFORMS)
translate_path_input(android-sdk ANDROID_SDK_ROOT) translate_path_input(android-sdk ANDROID_SDK_ROOT)
translate_path_input(android-ndk ANDROID_NDK_ROOT) translate_path_input(android-ndk ANDROID_NDK_ROOT)

View File

@ -145,7 +145,8 @@ The following table describes the mapping of configure options to CMake argument
| -opengl <api> | -DINPUT_opengl=<api> | | | -opengl <api> | -DINPUT_opengl=<api> | |
| -opengles3 | -DFEATURE_opengles3=ON | | | -opengles3 | -DFEATURE_opengles3=ON | |
| -egl | -DFEATURE_egl=ON | | | -egl | -DFEATURE_egl=ON | |
| -qpa <name> | -DQT_QPA_DEFAULT_PLATFORM=<name> | | | -qpa <name>;...;<name_n> | -DQT_QPA_PLATFORMS=<name>;...;<name_n> | |
| -default-qpa <name> | -DQT_QPA_DEFAULT_PLATFORM=<name> | |
| -xcb-xlib | -DFEATURE_xcb_xlib=ON | | | -xcb-xlib | -DFEATURE_xcb_xlib=ON | |
| -direct2d | -DFEATURE_direct2d=ON | | | -direct2d | -DFEATURE_direct2d=ON | |
| -directfb | -DFEATURE_directfb=ON | | | -directfb | -DFEATURE_directfb=ON | |

View File

@ -290,8 +290,10 @@ Gui, printing, widget options:
-opengles3 ........... Enable OpenGL ES 3.x support instead of ES 2.x [auto] -opengles3 ........... Enable OpenGL ES 3.x support instead of ES 2.x [auto]
-egl ................. Enable EGL support [auto] -egl ................. Enable EGL support [auto]
-qpa <name> .......... Select default QPA backend(s) (e.g., xcb, cocoa, windows) -qpa <qpa1>[;<qpa2>] . Select supported QPA backend(s) (e.g., xcb, cocoa,
A prioritized list separated by semi-colons. windows). A list separated by semi-colons.
-default-qpa <name> .. Select the default QPA backend (e.g., xcb, cocoa,
windows).
-xcb-xlib............. Enable Xcb-Xlib support [auto] -xcb-xlib............. Enable Xcb-Xlib support [auto]
Platform backends: Platform backends:

View File

@ -7,7 +7,9 @@ qt_find_package(WrapPNG PROVIDED_TARGETS WrapPNG::WrapPNG)
qt_find_package(WrapFreetype PROVIDED_TARGETS WrapFreetype::WrapFreetype) qt_find_package(WrapFreetype PROVIDED_TARGETS WrapFreetype::WrapFreetype)
if (QT_FEATURE_gui) if (QT_FEATURE_gui)
if(WIN32) if(QT_QPA_PLATFORMS)
list(GET QT_QPA_PLATFORMS 0 _default_platform)
elseif(WIN32)
set(_default_platform "windows") set(_default_platform "windows")
elseif(ANDROID) elseif(ANDROID)
set(_default_platform "android") set(_default_platform "android")
@ -30,6 +32,11 @@ if (QT_FEATURE_gui)
endif() endif()
set(QT_QPA_DEFAULT_PLATFORM "${_default_platform}" CACHE STRING "QPA default platform") set(QT_QPA_DEFAULT_PLATFORM "${_default_platform}" CACHE STRING "QPA default platform")
if(NOT "${QT_QPA_DEFAULT_PLATFORM}" IN_LIST QT_QPA_PLATFORMS)
list(APPEND QT_QPA_PLATFORMS "${QT_QPA_DEFAULT_PLATFORM}")
set(QT_QPA_PLATFORMS "${QT_QPA_PLATFORMS}" CACHE STRING
"QPA platforms deployed by default" FORCE)
endif()
endif() endif()
# Silence warnings in 3rdparty code # Silence warnings in 3rdparty code

View File

@ -27,7 +27,8 @@ qt_commandline_option(opengl TYPE optionalString VALUES no yes desktop es2 dynam
qt_commandline_option(opengl-es-2 TYPE void NAME opengl VALUE es2) qt_commandline_option(opengl-es-2 TYPE void NAME opengl VALUE es2)
qt_commandline_option(opengles3 TYPE boolean) qt_commandline_option(opengles3 TYPE boolean)
qt_commandline_option(openvg TYPE boolean) qt_commandline_option(openvg TYPE boolean)
qt_commandline_option(qpa TYPE string NAME qpa_default_platform) qt_commandline_option(qpa TYPE string NAME qpa_platforms)
qt_commandline_option(default-qpa TYPE string NAME qpa_default_platform)
qt_commandline_option(sm TYPE boolean NAME sessionmanager) qt_commandline_option(sm TYPE boolean NAME sessionmanager)
qt_commandline_option(tslib TYPE boolean) qt_commandline_option(tslib TYPE boolean)
qt_commandline_option(vulkan TYPE boolean) qt_commandline_option(vulkan TYPE boolean)

View File

@ -9,7 +9,7 @@ qt_find_package(EGL)
qt_internal_add_plugin(QAndroidIntegrationPlugin qt_internal_add_plugin(QAndroidIntegrationPlugin
OUTPUT_NAME qtforandroid OUTPUT_NAME qtforandroid
PLUGIN_TYPE platforms PLUGIN_TYPE platforms
DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES android DEFAULT_IF "android" IN_LIST QT_QPA_PLATFORMS
SOURCES SOURCES
androidcontentfileengine.cpp androidcontentfileengine.h androidcontentfileengine.cpp androidcontentfileengine.h
androiddeadlockprotector.h androiddeadlockprotector.h

View File

@ -7,7 +7,7 @@
qt_internal_add_plugin(QCocoaIntegrationPlugin qt_internal_add_plugin(QCocoaIntegrationPlugin
OUTPUT_NAME qcocoa OUTPUT_NAME qcocoa
DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES cocoa DEFAULT_IF "cocoa" IN_LIST QT_QPA_PLATFORMS
PLUGIN_TYPE platforms PLUGIN_TYPE platforms
SOURCES SOURCES
main.mm main.mm

View File

@ -92,7 +92,7 @@ endif()
qt_internal_add_plugin(QEglFSIntegrationPlugin qt_internal_add_plugin(QEglFSIntegrationPlugin
OUTPUT_NAME qeglfs OUTPUT_NAME qeglfs
PLUGIN_TYPE platforms PLUGIN_TYPE platforms
DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES eglfs DEFAULT_IF "eglfs" IN_LIST QT_QPA_PLATFORMS
SOURCES SOURCES
qeglfsmain.cpp qeglfsmain.cpp
DEFINES DEFINES

View File

@ -21,7 +21,7 @@ endif()
qt_internal_add_plugin(QIOSIntegrationPlugin qt_internal_add_plugin(QIOSIntegrationPlugin
OUTPUT_NAME qios OUTPUT_NAME qios
STATIC # Force static, even in shared builds STATIC # Force static, even in shared builds
DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES ios DEFAULT_IF "ios" IN_LIST QT_QPA_PLATFORMS
PLUGIN_TYPE platforms PLUGIN_TYPE platforms
SOURCES SOURCES
plugin.mm plugin.mm

View File

@ -8,7 +8,7 @@
qt_internal_add_plugin(QLinuxFbIntegrationPlugin qt_internal_add_plugin(QLinuxFbIntegrationPlugin
OUTPUT_NAME qlinuxfb OUTPUT_NAME qlinuxfb
PLUGIN_TYPE platforms PLUGIN_TYPE platforms
DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES linuxfb DEFAULT_IF "linuxfb" IN_LIST QT_QPA_PLATFORMS
SOURCES SOURCES
main.cpp main.cpp
qlinuxfbintegration.cpp qlinuxfbintegration.h qlinuxfbintegration.cpp qlinuxfbintegration.h

View File

@ -10,7 +10,7 @@ qt_find_package(WrapFreetype PROVIDED_TARGETS WrapFreetype::WrapFreetype)
qt_internal_add_plugin(QMinimalIntegrationPlugin qt_internal_add_plugin(QMinimalIntegrationPlugin
OUTPUT_NAME qminimal OUTPUT_NAME qminimal
PLUGIN_TYPE platforms PLUGIN_TYPE platforms
DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES minimal DEFAULT_IF "minimal" IN_LIST QT_QPA_PLATFORMS
SOURCES SOURCES
main.cpp main.cpp
qminimalbackingstore.cpp qminimalbackingstore.h qminimalbackingstore.cpp qminimalbackingstore.h

View File

@ -10,7 +10,7 @@ qt_find_package(EGL)
qt_internal_add_plugin(QMinimalEglIntegrationPlugin qt_internal_add_plugin(QMinimalEglIntegrationPlugin
OUTPUT_NAME qminimalegl OUTPUT_NAME qminimalegl
PLUGIN_TYPE platforms PLUGIN_TYPE platforms
DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES minimalegl DEFAULT_IF "minimalegl" IN_LIST QT_QPA_PLATFORMS
SOURCES SOURCES
main.cpp main.cpp
qminimaleglintegration.cpp qminimaleglintegration.h qminimaleglintegration.cpp qminimaleglintegration.h

View File

@ -8,7 +8,7 @@
qt_internal_add_plugin(QOffscreenIntegrationPlugin qt_internal_add_plugin(QOffscreenIntegrationPlugin
OUTPUT_NAME qoffscreen OUTPUT_NAME qoffscreen
PLUGIN_TYPE platforms PLUGIN_TYPE platforms
DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES offscreen DEFAULT_IF "offscreen" IN_LIST QT_QPA_PLATFORMS
SOURCES SOURCES
main.cpp main.cpp
qoffscreencommon.cpp qoffscreencommon.h qoffscreencommon.cpp qoffscreencommon.h

View File

@ -8,7 +8,7 @@
qt_internal_add_plugin(QQnxIntegrationPlugin qt_internal_add_plugin(QQnxIntegrationPlugin
OUTPUT_NAME qqnx OUTPUT_NAME qqnx
PLUGIN_TYPE platforms PLUGIN_TYPE platforms
DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES qnx DEFAULT_IF "qnx" IN_LIST QT_QPA_PLATFORMS
SOURCES SOURCES
main.cpp main.h main.cpp main.h
qqnxabstractcover.h qqnxabstractcover.h

View File

@ -6,7 +6,7 @@ qt_find_package(WrapFreetype PROVIDED_TARGETS WrapFreetype::WrapFreetype)
qt_internal_add_plugin(QVkKhrDisplayIntegrationPlugin qt_internal_add_plugin(QVkKhrDisplayIntegrationPlugin
OUTPUT_NAME qvkkhrdisplay OUTPUT_NAME qvkkhrdisplay
PLUGIN_TYPE platforms PLUGIN_TYPE platforms
DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES vkkhrdisplay DEFAULT_IF "vkkhrdisplay" IN_LIST QT_QPA_PLATFORMS
SOURCES SOURCES
main.cpp main.cpp
qvkkhrdisplayintegration.cpp qvkkhrdisplayintegration.h qvkkhrdisplayintegration.cpp qvkkhrdisplayintegration.h

View File

@ -8,7 +8,7 @@
qt_internal_add_plugin(QVncIntegrationPlugin qt_internal_add_plugin(QVncIntegrationPlugin
OUTPUT_NAME qvnc OUTPUT_NAME qvnc
PLUGIN_TYPE platforms PLUGIN_TYPE platforms
DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES vnc DEFAULT_IF "vnc" IN_LIST QT_QPA_PLATFORMS
SOURCES SOURCES
main.cpp main.cpp
qvnc.cpp qvnc_p.h qvnc.cpp qvnc_p.h

View File

@ -7,7 +7,7 @@
qt_internal_add_plugin(QWasmIntegrationPlugin qt_internal_add_plugin(QWasmIntegrationPlugin
OUTPUT_NAME qwasm OUTPUT_NAME qwasm
DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES wasm DEFAULT_IF "wasm" IN_LIST QT_QPA_PLATFORMS
PLUGIN_TYPE platforms PLUGIN_TYPE platforms
SOURCES SOURCES
main.cpp main.cpp

View File

@ -8,7 +8,7 @@
qt_internal_add_plugin(QWindowsIntegrationPlugin qt_internal_add_plugin(QWindowsIntegrationPlugin
OUTPUT_NAME qwindows OUTPUT_NAME qwindows
PLUGIN_TYPE platforms PLUGIN_TYPE platforms
DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES windows DEFAULT_IF "windows" IN_LIST QT_QPA_PLATFORMS
SOURCES SOURCES
main.cpp main.cpp
qtwindowsglobal.h qtwindowsglobal.h

View File

@ -164,7 +164,7 @@ endif()
qt_internal_add_plugin(QXcbIntegrationPlugin qt_internal_add_plugin(QXcbIntegrationPlugin
OUTPUT_NAME qxcb OUTPUT_NAME qxcb
PLUGIN_TYPE platforms PLUGIN_TYPE platforms
DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES xcb DEFAULT_IF "xcb" IN_LIST QT_QPA_PLATFORMS
SOURCES SOURCES
qxcbmain.cpp qxcbmain.cpp
DEFINES DEFINES