qmake: Link static plugins even in shared Qt builds
It's perfectly possible to create static plugins in an otherwise shared Qt build, but the logic to import these plugins into applications was assuming a fully static Qt build. We now handle this more granularly. Change-Id: Iacfa72f04c7918613b50ca87cf123e7f4c0841d5 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
6ebc4249e2
commit
f3cd571687
@ -613,6 +613,13 @@ function(qt_generate_plugin_pri_file target pri_file_var)
|
||||
list(REMOVE_DUPLICATES plugin_deps)
|
||||
list(JOIN plugin_deps " " plugin_deps)
|
||||
|
||||
list(APPEND module_config v2)
|
||||
get_target_property(target_type ${target} TYPE)
|
||||
if(target_type STREQUAL "STATIC_LIBRARY")
|
||||
list(APPEND module_config staticlib)
|
||||
endif()
|
||||
list(JOIN module_config " " module_config)
|
||||
|
||||
qt_path_join(pri_target_path ${QT_BUILD_DIR} ${INSTALL_MKSPECSDIR}/modules)
|
||||
qt_path_join(pri_file "${pri_target_path}" "qt_plugin_${plugin_name}.pri")
|
||||
qt_configure_file(OUTPUT "${pri_file}"
|
||||
@ -620,6 +627,7 @@ function(qt_generate_plugin_pri_file target pri_file_var)
|
||||
QT_PLUGIN.${plugin_name}.EXTENDS = ${plugin_extends}
|
||||
QT_PLUGIN.${plugin_name}.DEPENDS = ${plugin_deps}
|
||||
QT_PLUGIN.${plugin_name}.CLASS_NAME = ${plugin_class_name}
|
||||
QT_PLUGIN.${plugin_name}.module_config = ${module_config}
|
||||
QT_PLUGINS += ${plugin_name}
|
||||
")
|
||||
set(${pri_file_var} "${pri_file}" PARENT_SCOPE)
|
||||
|
@ -76,7 +76,7 @@ all_qt_module_deps = $$resolve_depends(qt_module_deps, "QT.", ".depends" ".run_d
|
||||
QTPLUGIN = $$unique($$list($$lower($$QTPLUGIN)))
|
||||
|
||||
# Sanitize requested plugins, and add any default plugins
|
||||
import_plugins:qtConfig(static) {
|
||||
import_plugins {
|
||||
manualplugs = $$QTPLUGIN # User may specify plugins. Mostly legacy.
|
||||
autoplugs = # Auto-added plugins.
|
||||
# First round: explicitly specified modules.
|
||||
@ -129,14 +129,16 @@ import_plugins:qtConfig(static) {
|
||||
warning("Redundant entries in QTPLUGIN: $$extraplugs")
|
||||
}
|
||||
|
||||
# Only link against plugins in static builds
|
||||
!isEmpty(QTPLUGIN):qtConfig(static) {
|
||||
IMPORT_FILE_CONT = \
|
||||
"// This file is autogenerated by qmake. It imports static plugin classes for" \
|
||||
"// static plugins specified using QTPLUGIN and QT_PLUGIN_CLASS.<plugin> variables." \
|
||||
"$${LITERAL_HASH}include <QtPlugin>"
|
||||
|
||||
# Link static plugins
|
||||
!isEmpty(QTPLUGIN) {
|
||||
for (plug, QTPLUGIN) {
|
||||
module_config = $$eval(QT_PLUGIN.$${plug}.module_config)
|
||||
isEmpty(module_config):!qtConfig(static): \
|
||||
next() # Compatibility with older modules
|
||||
|
||||
!contains(module_config, staticlib): \
|
||||
next()
|
||||
|
||||
plug_class = $$eval(QT_PLUGIN.$${plug}.CLASS_NAME)
|
||||
!isEmpty(plug_class): \
|
||||
IMPORT_FILE_CONT += "Q_IMPORT_PLUGIN($$plug_class)"
|
||||
@ -161,12 +163,20 @@ import_plugins:qtConfig(static) {
|
||||
}
|
||||
}
|
||||
|
||||
TARGET_BASENAME = $$lower($$basename(TARGET))
|
||||
TARGET_BASENAME ~= s/\s/_/g
|
||||
IMPORT_CPP = $$OUT_PWD/$${TARGET_BASENAME}_plugin_import.cpp
|
||||
write_file($$IMPORT_CPP, IMPORT_FILE_CONT)|error()
|
||||
GENERATED_SOURCES += $$IMPORT_CPP
|
||||
QMAKE_DISTCLEAN += $$IMPORT_CPP
|
||||
!isEmpty(IMPORT_FILE_CONT) {
|
||||
IMPORT_FILE_CONT = \
|
||||
"// This file is autogenerated by qmake. It imports static plugin classes for" \
|
||||
"// static plugins specified using QTPLUGIN and QT_PLUGIN_CLASS.<plugin> variables." \
|
||||
"$${LITERAL_HASH}include <QtPlugin>" \
|
||||
"$$IMPORT_FILE_CONT"
|
||||
|
||||
TARGET_BASENAME = $$lower($$basename(TARGET))
|
||||
TARGET_BASENAME ~= s/\s/_/g
|
||||
IMPORT_CPP = $$OUT_PWD/$${TARGET_BASENAME}_plugin_import.cpp
|
||||
write_file($$IMPORT_CPP, IMPORT_FILE_CONT)|error()
|
||||
GENERATED_SOURCES += $$IMPORT_CPP
|
||||
QMAKE_DISTCLEAN += $$IMPORT_CPP
|
||||
}
|
||||
}
|
||||
|
||||
# target variable, flag source variable
|
||||
|
Loading…
x
Reference in New Issue
Block a user