cmake: implement default qpa plugin behavior for static builds
This is done by adding a DEFAULT_IF argument to add_qt_plugin, which accepts if-evaluated expressions. e.g. add_qt_plugin(myplugin DEFAULT_IF ${foo} STREQUAL ${bar} ... ) so that this mechanism can be reused later if necessary. Change-Id: I7eba9adaaa28e55a4f0f94cf206e868b990027e6 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
5769e1a2f6
commit
a5b78a3660
@ -1449,7 +1449,7 @@ function(add_qt_plugin target)
|
|||||||
|
|
||||||
qt_parse_all_arguments(arg "add_qt_plugin" "STATIC;EXCEPTIONS"
|
qt_parse_all_arguments(arg "add_qt_plugin" "STATIC;EXCEPTIONS"
|
||||||
"TYPE;CLASS_NAME;OUTPUT_DIRECTORY;INSTALL_DIRECTORY;ARCHIVE_INSTALL_DIRECTORY"
|
"TYPE;CLASS_NAME;OUTPUT_DIRECTORY;INSTALL_DIRECTORY;ARCHIVE_INSTALL_DIRECTORY"
|
||||||
"${__default_private_args};${__default_public_args}" ${ARGN})
|
"${__default_private_args};${__default_public_args};DEFAULT_IF" ${ARGN})
|
||||||
|
|
||||||
set(output_directory_default "${QT_BUILD_DIR}/${INSTALL_PLUGINSDIR}/${arg_TYPE}")
|
set(output_directory_default "${QT_BUILD_DIR}/${INSTALL_PLUGINSDIR}/${arg_TYPE}")
|
||||||
|
|
||||||
@ -1501,7 +1501,15 @@ function(add_qt_plugin target)
|
|||||||
set_property(TARGET "${qt_module}" APPEND PROPERTY QT_PLUGINS "${target}")
|
set_property(TARGET "${qt_module}" APPEND PROPERTY QT_PLUGINS "${target}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set_property(TARGET "${target}" APPEND PROPERTY EXPORT_PROPERTIES "QT_PLUGIN_CLASS_NAME;QT_MODULE")
|
set(_default_plugin 1)
|
||||||
|
if (DEFINED arg_DEFAULT_IF)
|
||||||
|
if (NOT ${arg_DEFAULT_IF})
|
||||||
|
set(_default_plugin 0)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set_property(TARGET "${target}" PROPERTY QT_DEFAULT_PLUGIN "${_default_plugin}")
|
||||||
|
set_property(TARGET "${target}" APPEND PROPERTY EXPORT_PROPERTIES "QT_PLUGIN_CLASS_NAME;QT_MODULE;QT_DEFAULT_PLUGIN")
|
||||||
|
|
||||||
extend_target("${target}"
|
extend_target("${target}"
|
||||||
SOURCES ${arg_SOURCES}
|
SOURCES ${arg_SOURCES}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
if(NOT @BUILD_SHARED_LIBS@)
|
if(NOT @BUILD_SHARED_LIBS@)
|
||||||
set(_module_target "@INSTALL_CMAKE_NAMESPACE@::@QT_MODULE@")
|
set(_module_target "@INSTALL_CMAKE_NAMESPACE@::@QT_MODULE@")
|
||||||
|
|
||||||
set(_default_plugins_genex "$<GENEX_EVAL:$<TARGET_PROPERTY:QT_DEFAULT_PLUGINS>>")
|
set(_default_plugins_are_enabled "$<GENEX_EVAL:$<TARGET_PROPERTY:QT_DEFAULT_PLUGINS>>")
|
||||||
set(_manual_plugins_genex "$<GENEX_EVAL:$<TARGET_PROPERTY:QT_PLUGINS>>")
|
set(_manual_plugins_genex "$<GENEX_EVAL:$<TARGET_PROPERTY:QT_PLUGINS>>")
|
||||||
set(_no_plugins_genex "$<GENEX_EVAL:$<TARGET_PROPERTY:QT_NO_PLUGINS>>")
|
set(_no_plugins_genex "$<GENEX_EVAL:$<TARGET_PROPERTY:QT_NO_PLUGINS>>")
|
||||||
|
|
||||||
@ -15,17 +15,17 @@ if(NOT @BUILD_SHARED_LIBS@)
|
|||||||
continue()
|
continue()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(_user_specified_genex "$<IN_LIST:${_plugin_target},${_manual_plugins_genex}>")
|
set(_plugin_is_default "$<TARGET_PROPERTY:${_plugin_target},QT_DEFAULT_PLUGIN>")
|
||||||
|
set(_plugin_is_not_blacklisted "$<NOT:$<IN_LIST:${_plugin_target},${_no_plugins_genex}>>")
|
||||||
|
set(_plugin_is_whitelisted "$<IN_LIST:${_plugin_target},${_manual_plugins_genex}>")
|
||||||
|
|
||||||
string(CONCAT _plugin_condition
|
string(CONCAT _plugin_condition
|
||||||
"$<BOOL:$<OR:"
|
"$<BOOL:$<OR:"
|
||||||
# Add this plugin if it\'s in the list of manual plugins or plugins for the type
|
"${_plugin_is_whitelisted},"
|
||||||
"${_user_specified_genex},"
|
|
||||||
# Add this plugin if the default plugins haven't been disabled, the module of the plug-in
|
|
||||||
# is either empty or equal to the module name, and the user hasn't blacklisted it
|
|
||||||
"$<AND:"
|
"$<AND:"
|
||||||
"${_default_plugins_genex},"
|
"${_default_plugins_are_enabled},"
|
||||||
"$<NOT:$<IN_LIST:${_plugin_target},${_no_plugins_genex}>>"
|
"${_plugin_is_default},"
|
||||||
|
"${_plugin_is_not_blacklisted}"
|
||||||
">"
|
">"
|
||||||
">>"
|
">>"
|
||||||
)
|
)
|
||||||
|
@ -38,6 +38,18 @@ define_property(TARGET
|
|||||||
For instance, Sql for qsqlite"
|
For instance, Sql for qsqlite"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
define_property(TARGET
|
||||||
|
PROPERTY
|
||||||
|
QT_DEFAULT_PLUGIN
|
||||||
|
BRIEF_DOCS
|
||||||
|
"Indicates whether a plug-in is added by default."
|
||||||
|
FULL_DOCS
|
||||||
|
"This is a property on Qt plug-ins.
|
||||||
|
It is mainly used to indicate if a plug-in should be added
|
||||||
|
to the default set of plug-ins when building a static app -
|
||||||
|
for instance, which QPA should be linked."
|
||||||
|
)
|
||||||
|
|
||||||
define_property(GLOBAL
|
define_property(GLOBAL
|
||||||
PROPERTY
|
PROPERTY
|
||||||
QT_KNOWN_PLUGINS
|
QT_KNOWN_PLUGINS
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
add_qt_plugin(qtforandroid
|
add_qt_plugin(qtforandroid
|
||||||
TYPE platforms
|
TYPE platforms
|
||||||
|
DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES android # special case
|
||||||
SOURCES
|
SOURCES
|
||||||
androidcontentfileengine.cpp androidcontentfileengine.h
|
androidcontentfileengine.cpp androidcontentfileengine.h
|
||||||
androiddeadlockprotector.cpp androiddeadlockprotector.h
|
androiddeadlockprotector.cpp androiddeadlockprotector.h
|
||||||
|
@ -9,6 +9,7 @@ qt_find_package(Cups PROVIDED_TARGETS Cups::Cups)
|
|||||||
|
|
||||||
add_qt_plugin(qcocoa
|
add_qt_plugin(qcocoa
|
||||||
TYPE platforms
|
TYPE platforms
|
||||||
|
DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES cocoa # special case
|
||||||
CLASS_NAME QCocoaIntegrationPlugin
|
CLASS_NAME QCocoaIntegrationPlugin
|
||||||
SOURCES
|
SOURCES
|
||||||
main.mm
|
main.mm
|
||||||
|
@ -80,6 +80,7 @@ extend_target(EglFSDeviceIntegration CONDITION QT_FEATURE_opengl
|
|||||||
add_qt_plugin(qeglfs
|
add_qt_plugin(qeglfs
|
||||||
TYPE platforms
|
TYPE platforms
|
||||||
CLASS_NAME QEglFSIntegrationPlugin
|
CLASS_NAME QEglFSIntegrationPlugin
|
||||||
|
DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES eglfs # special case
|
||||||
SOURCES
|
SOURCES
|
||||||
qeglfsmain.cpp
|
qeglfsmain.cpp
|
||||||
DEFINES
|
DEFINES
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
add_qt_plugin(qlinuxfb
|
add_qt_plugin(qlinuxfb
|
||||||
TYPE platforms
|
TYPE platforms
|
||||||
CLASS_NAME QLinuxFbIntegrationPlugin
|
CLASS_NAME QLinuxFbIntegrationPlugin
|
||||||
|
DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES linuxfb # special case
|
||||||
SOURCES
|
SOURCES
|
||||||
main.cpp
|
main.cpp
|
||||||
qlinuxfbintegration.cpp qlinuxfbintegration.h
|
qlinuxfbintegration.cpp qlinuxfbintegration.h
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
add_qt_plugin(qminimal
|
add_qt_plugin(qminimal
|
||||||
TYPE platforms
|
TYPE platforms
|
||||||
CLASS_NAME QMinimalIntegrationPlugin
|
CLASS_NAME QMinimalIntegrationPlugin
|
||||||
|
DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES minimal # special case
|
||||||
SOURCES
|
SOURCES
|
||||||
main.cpp
|
main.cpp
|
||||||
qminimalbackingstore.cpp qminimalbackingstore.h
|
qminimalbackingstore.cpp qminimalbackingstore.h
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
add_qt_plugin(qminimalegl
|
add_qt_plugin(qminimalegl
|
||||||
TYPE platforms
|
TYPE platforms
|
||||||
CLASS_NAME QMinimalEglIntegrationPlugin
|
CLASS_NAME QMinimalEglIntegrationPlugin
|
||||||
|
DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES minimalegl # special case
|
||||||
SOURCES
|
SOURCES
|
||||||
main.cpp
|
main.cpp
|
||||||
qminimaleglintegration.cpp qminimaleglintegration.h
|
qminimaleglintegration.cpp qminimaleglintegration.h
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
add_qt_plugin(qoffscreen
|
add_qt_plugin(qoffscreen
|
||||||
TYPE platforms
|
TYPE platforms
|
||||||
CLASS_NAME QOffscreenIntegrationPlugin
|
CLASS_NAME QOffscreenIntegrationPlugin
|
||||||
|
DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES offscreen # special case
|
||||||
SOURCES
|
SOURCES
|
||||||
main.cpp
|
main.cpp
|
||||||
qoffscreencommon.cpp qoffscreencommon.h
|
qoffscreencommon.cpp qoffscreencommon.h
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
add_qt_plugin(qvnc
|
add_qt_plugin(qvnc
|
||||||
TYPE platforms
|
TYPE platforms
|
||||||
CLASS_NAME QVncIntegrationPlugin
|
CLASS_NAME QVncIntegrationPlugin
|
||||||
|
DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES vnc # special case
|
||||||
SOURCES
|
SOURCES
|
||||||
main.cpp
|
main.cpp
|
||||||
qvnc.cpp qvnc_p.h
|
qvnc.cpp qvnc_p.h
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
add_qt_plugin(qwindows
|
add_qt_plugin(qwindows
|
||||||
TYPE platforms
|
TYPE platforms
|
||||||
CLASS_NAME QWindowsIntegrationPlugin
|
CLASS_NAME QWindowsIntegrationPlugin
|
||||||
|
DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES windows # special case
|
||||||
SOURCES
|
SOURCES
|
||||||
main.cpp
|
main.cpp
|
||||||
qtwindowsglobal.h
|
qtwindowsglobal.h
|
||||||
|
@ -190,6 +190,7 @@ extend_target(XcbQpa CONDITION QT_FEATURE_fontconfig AND QT_FEATURE_xcb_native_p
|
|||||||
add_qt_plugin(qxcb
|
add_qt_plugin(qxcb
|
||||||
TYPE platforms
|
TYPE platforms
|
||||||
CLASS_NAME QXcbIntegrationPlugin
|
CLASS_NAME QXcbIntegrationPlugin
|
||||||
|
DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES xcb # special case
|
||||||
SOURCES
|
SOURCES
|
||||||
qxcbmain.cpp
|
qxcbmain.cpp
|
||||||
DEFINES
|
DEFINES
|
||||||
|
Loading…
x
Reference in New Issue
Block a user