Improve linking against static Qt plugins
* Detect a static Qt build and link against Qt plugins automatically in that case (without the necassity to set `STATIC_LINKAGE`) * Add offscreen support on UNIX platforms as it is useful for testing on headless systems * Add wayland support if available * Populate `QT_TEST_LIBRARIES` in case we're not building an app because the plugins are still required when building tests
This commit is contained in:
parent
605dca019c
commit
8a4b865c28
|
@ -10,7 +10,7 @@ set(META_APP_DESCRIPTION
|
|||
"Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models")
|
||||
set(META_VERSION_MAJOR 6)
|
||||
set(META_VERSION_MINOR 6)
|
||||
set(META_VERSION_PATCH 0)
|
||||
set(META_VERSION_PATCH 1)
|
||||
set(META_APP_VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH})
|
||||
|
||||
project(${META_PROJECT_NAME})
|
||||
|
@ -198,7 +198,7 @@ include(ConfigHeader)
|
|||
|
||||
# configure test target
|
||||
include(TestUtilities)
|
||||
set(QT_TEST_LIBRARIES ${CPP_UTILITIES_LIB} ${META_TARGET_NAME})
|
||||
list(APPEND QT_TEST_LIBRARIES ${CPP_UTILITIES_LIB} ${META_TARGET_NAME})
|
||||
use_qt_module(LIBRARIES_VARIABLE "QT_TEST_LIBRARIES" PREFIX "${QT_PACKAGE_PREFIX}" MODULE "Test")
|
||||
foreach (TEST ${QT_TESTS})
|
||||
configure_test_target(TEST_NAME "${TEST}_tests" SRC_FILES "tests/${TEST}.cpp" LIBRARIES "${QT_TEST_LIBRARIES}")
|
||||
|
|
|
@ -120,14 +120,27 @@ if (NOT DEFINED TLS_SUPPORT)
|
|||
endif ()
|
||||
|
||||
# built-in platform, imageformat and iconengine plugins when linking statically against Qt
|
||||
if (STATIC_LINKAGE AND META_PROJECT_IS_APPLICATION)
|
||||
message(STATUS "Linking application ${META_PROJECT_NAME} against Qt plugins because static linkage is enabled.")
|
||||
if (TARGET "${QT_PACKAGE_PREFIX}::Core")
|
||||
get_target_property(QT_TARGET_TYPE "${QT_PACKAGE_PREFIX}::Core" TYPE)
|
||||
endif ()
|
||||
if (STATIC_LINKAGE OR QT_TARGET_TYPE STREQUAL STATIC_LIBRARY)
|
||||
if (META_PROJECT_IS_APPLICATION)
|
||||
set(QT_PLUGINS_LIBRARIES_VARIABLE PRIVATE_LIBRARIES)
|
||||
else ()
|
||||
set(QT_PLUGINS_LIBRARIES_VARIABLE QT_TEST_LIBRARIES)
|
||||
endif ()
|
||||
message(
|
||||
STATUS
|
||||
"Linking ${META_PROJECT_NAME} (${QT_PLUGINS_LIBRARIES_VARIABLE}) against Qt plugins because static linkage is enabled or a static Qt build is used."
|
||||
)
|
||||
|
||||
if (Gui IN_LIST QT_MODULES
|
||||
OR Widgets IN_LIST QT_MODULES
|
||||
OR Quick IN_LIST QT_MODULES)
|
||||
if (WIN32)
|
||||
if (WIN32 AND TARGET "${QT_PACKAGE_PREFIX}::QWindowsIntegrationPlugin")
|
||||
use_qt_module(
|
||||
LIBRARIES_VARIABLE
|
||||
"${QT_PLUGINS_LIBRARIES_VARIABLE}"
|
||||
PREFIX
|
||||
"${QT_PACKAGE_PREFIX}"
|
||||
MODULE
|
||||
|
@ -135,8 +148,10 @@ if (STATIC_LINKAGE AND META_PROJECT_IS_APPLICATION)
|
|||
PLUGINS
|
||||
WindowsIntegration
|
||||
ONLY_PLUGINS)
|
||||
elseif (APPLE)
|
||||
elseif (APPLE AND TARGET "${QT_PACKAGE_PREFIX}::QCocoaIntegrationPlugin")
|
||||
use_qt_module(
|
||||
LIBRARIES_VARIABLE
|
||||
"${QT_PLUGINS_LIBRARIES_VARIABLE}"
|
||||
PREFIX
|
||||
"${QT_PACKAGE_PREFIX}"
|
||||
MODULE
|
||||
|
@ -144,8 +159,23 @@ if (STATIC_LINKAGE AND META_PROJECT_IS_APPLICATION)
|
|||
PLUGINS
|
||||
CocoaIntegration
|
||||
ONLY_PLUGINS)
|
||||
elseif (TARGET "${QT_PACKAGE_PREFIX}::QXcbIntegrationPlugin")
|
||||
endif ()
|
||||
if (UNIX AND TARGET "${QT_PACKAGE_PREFIX}::QOffscreenIntegrationPlugin")
|
||||
use_qt_module(
|
||||
LIBRARIES_VARIABLE
|
||||
"${QT_PLUGINS_LIBRARIES_VARIABLE}"
|
||||
PREFIX
|
||||
"${QT_PACKAGE_PREFIX}"
|
||||
MODULE
|
||||
Gui
|
||||
PLUGINS
|
||||
OffscreenIntegration
|
||||
ONLY_PLUGINS)
|
||||
endif ()
|
||||
if (TARGET "${QT_PACKAGE_PREFIX}::QXcbIntegrationPlugin")
|
||||
use_qt_module(
|
||||
LIBRARIES_VARIABLE
|
||||
"${QT_PLUGINS_LIBRARIES_VARIABLE}"
|
||||
PREFIX
|
||||
"${QT_PACKAGE_PREFIX}"
|
||||
MODULE
|
||||
|
@ -153,8 +183,18 @@ if (STATIC_LINKAGE AND META_PROJECT_IS_APPLICATION)
|
|||
PLUGINS
|
||||
XcbIntegration
|
||||
ONLY_PLUGINS)
|
||||
else ()
|
||||
message(WARNING "The required platform plugin for your platform is unknown an can not be linked in statically.")
|
||||
endif ()
|
||||
if (TARGET "${QT_PACKAGE_PREFIX}::QWaylandIntegrationPlugin")
|
||||
use_qt_module(
|
||||
LIBRARIES_VARIABLE
|
||||
"${QT_PLUGINS_LIBRARIES_VARIABLE}"
|
||||
PREFIX
|
||||
"${QT_PACKAGE_PREFIX}"
|
||||
MODULE
|
||||
Gui
|
||||
PLUGINS
|
||||
WaylandIntegration
|
||||
ONLY_PLUGINS)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
|
@ -166,6 +206,8 @@ if (STATIC_LINKAGE AND META_PROJECT_IS_APPLICATION)
|
|||
foreach (TLS_PLUGIN ${KNOWN_TLS_PLUGINS})
|
||||
if (TARGET "${QT_PACKAGE_PREFIX}::Q${TLS_PLUGIN}Plugin")
|
||||
use_qt_module(
|
||||
LIBRARIES_VARIABLE
|
||||
"${QT_PLUGINS_LIBRARIES_VARIABLE}"
|
||||
PREFIX
|
||||
"${QT_PACKAGE_PREFIX}"
|
||||
MODULE
|
||||
|
@ -192,6 +234,8 @@ if (STATIC_LINKAGE AND META_PROJECT_IS_APPLICATION)
|
|||
foreach (WIDGET_STYLE_PLUGIN ${KNOWN_WIDGET_STYLE_PLUGINS})
|
||||
if (TARGET "${QT_PACKAGE_PREFIX}::Q${WIDGET_STYLE_PLUGIN}Plugin")
|
||||
use_qt_module(
|
||||
LIBRARIES_VARIABLE
|
||||
"${QT_PLUGINS_LIBRARIES_VARIABLE}"
|
||||
PREFIX
|
||||
"${QT_PACKAGE_PREFIX}"
|
||||
MODULE
|
||||
|
@ -219,6 +263,8 @@ if (STATIC_LINKAGE AND META_PROJECT_IS_APPLICATION)
|
|||
list(REMOVE_ITEM IMAGE_FORMAT_SUPPORT Svg)
|
||||
else ()
|
||||
use_qt_module(
|
||||
LIBRARIES_VARIABLE
|
||||
"${QT_PLUGINS_LIBRARIES_VARIABLE}"
|
||||
PREFIX
|
||||
"${QT_PACKAGE_PREFIX}"
|
||||
MODULE
|
||||
|
@ -235,10 +281,12 @@ if (STATIC_LINKAGE AND META_PROJECT_IS_APPLICATION)
|
|||
|
||||
# ensure SVG plugins are built-in if configured
|
||||
if ((SVG_SUPPORT OR SVG_ICON_SUPPORT) AND NOT Svg IN_LIST QT_MODULES)
|
||||
use_qt_module(PREFIX "${QT_PACKAGE_PREFIX}" MODULE Svg)
|
||||
use_qt_module(LIBRARIES_VARIABLE "${QT_PLUGINS_LIBRARIES_VARIABLE}" PREFIX "${QT_PACKAGE_PREFIX}" MODULE Svg)
|
||||
endif ()
|
||||
if (SVG_SUPPORT)
|
||||
use_qt_module(
|
||||
LIBRARIES_VARIABLE
|
||||
"${QT_PLUGINS_LIBRARIES_VARIABLE}"
|
||||
PREFIX
|
||||
"${QT_PACKAGE_PREFIX}"
|
||||
MODULE
|
||||
|
@ -249,6 +297,8 @@ if (STATIC_LINKAGE AND META_PROJECT_IS_APPLICATION)
|
|||
endif ()
|
||||
if (SVG_ICON_SUPPORT)
|
||||
use_qt_module(
|
||||
LIBRARIES_VARIABLE
|
||||
"${QT_PLUGINS_LIBRARIES_VARIABLE}"
|
||||
PREFIX
|
||||
"${QT_PACKAGE_PREFIX}"
|
||||
MODULE
|
||||
|
|
Loading…
Reference in New Issue