cmake: Don't give plugins PUBLIC usage requirements

The pro2cmake.py conversion script faithfully reproduced the .pro files
for the plugins, which specified the libraries as public. But in CMake,
the implications of this are that public usage requirements should then
be propagated to consumers. We don't expect any consumers, since a
plugin is created as a MODULE library in CMake, so for Windows we don't
even have an import library to link with. The only exception to this is
for static builds where plugins are created as STATIC libraries
instead, but only in certain controlled situations do we then link to
plugins. Even then, usage requirements are not expected to propagate to
the consumers, so these relationships should always be specified as
private.

This change warns on any PUBLIC usage requirements specified for a
plugin. This check is disabled by default to avoid spamming CI builds
for repos that haven't been fixed yet. The check can be enabled by a
CMake cache option, which is intended for developers to use locally
when fixing this issue in other repos (all plugins in qtbase should
not trigger this warning as a result of changes in this commit).

Task-number: QTBUG-90819
Pick-to: 6.1
Change-Id: I09f2c8da77db1193ad3370f85d367dfc6ab7b9a6
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Craig Scott 2021-02-10 12:11:39 +11:00
parent 1f30bcf336
commit fe29159aad
42 changed files with 84 additions and 76 deletions

View File

@ -13,6 +13,23 @@ function(qt_internal_add_plugin target)
"${ARGN}"
)
# Put this behind a cache option for now. It's too noisy for general use
# until most repos are updated.
option(QT_WARN_PLUGIN_PUBLIC_KEYWORDS "Warn if a plugin specifies a PUBLIC keyword")
if(QT_WARN_PLUGIN_PUBLIC_KEYWORDS)
foreach(publicKeyword IN LISTS __default_public_args)
if(NOT "${arg_${publicKeyword}}" STREQUAL "")
string(REPLACE "PUBLIC_" "" privateKeyword "${publicKeyword}")
message(AUTHOR_WARNING
"Plugins are not intended to be linked to. "
"They should not have any public properties, but ${target} "
"sets ${publicKeyword} to the following value:\n"
" ${arg_${publicKeyword}}\n"
"Update your project to use ${privateKeyword} instead.\n")
endif()
endforeach()
endif()
qt_get_sanitized_plugin_type("${arg_TYPE}" plugin_type_escaped)
set(output_directory_default "${QT_BUILD_DIR}/${INSTALL_PLUGINSDIR}/${arg_TYPE}")

View File

@ -10,7 +10,7 @@ qt_internal_add_plugin(QEvdevKeyboardPlugin
DEFAULT_IF FALSE
SOURCES
main.cpp
PUBLIC_LIBRARIES
LIBRARIES
Qt::Core
Qt::CorePrivate
Qt::Gui

View File

@ -10,7 +10,7 @@ qt_internal_add_plugin(QEvdevMousePlugin
DEFAULT_IF FALSE
SOURCES
main.cpp
PUBLIC_LIBRARIES
LIBRARIES
Qt::Core
Qt::CorePrivate
Qt::Gui

View File

@ -10,7 +10,7 @@ qt_internal_add_plugin(QEvdevTabletPlugin
DEFAULT_IF FALSE
SOURCES
main.cpp
PUBLIC_LIBRARIES
LIBRARIES
Qt::Core
Qt::CorePrivate
Qt::Gui

View File

@ -10,7 +10,7 @@ qt_internal_add_plugin(QEvdevTouchScreenPlugin
DEFAULT_IF FALSE
SOURCES
main.cpp
PUBLIC_LIBRARIES
LIBRARIES
Qt::Core
Qt::CorePrivate
Qt::Gui

View File

@ -10,7 +10,7 @@ qt_internal_add_plugin(QLibInputPlugin
DEFAULT_IF FALSE
SOURCES
main.cpp
PUBLIC_LIBRARIES
LIBRARIES
Qt::Core
Qt::CorePrivate
Qt::Gui

View File

@ -12,7 +12,7 @@ qt_internal_add_plugin(QTsLibPlugin
DEFAULT_IF FALSE
SOURCES
main.cpp
PUBLIC_LIBRARIES
LIBRARIES
PkgConfig::Tslib
Qt::Core
Qt::CorePrivate

View File

@ -17,7 +17,7 @@ qt_internal_add_plugin(QTuioTouchPlugin
qtuiotoken_p.h
DEFINES
QT_NO_FOREACH
PUBLIC_LIBRARIES
LIBRARIES
Qt::Core
Qt::CorePrivate
Qt::Gui

View File

@ -11,9 +11,8 @@ qt_internal_add_plugin(QGifPlugin
main.cpp main.h
qgifhandler.cpp qgifhandler_p.h
LIBRARIES # special case
Qt::GuiPrivate # special case
PUBLIC_LIBRARIES # special case
Qt::Gui # special case
Qt::GuiPrivate # special case
)
#### Keys ignored in scope 1:.:.:gif.pro:<TRUE>:

View File

@ -10,7 +10,7 @@ qt_internal_add_plugin(QICOPlugin
SOURCES
main.cpp main.h
qicohandler.cpp qicohandler.h
PUBLIC_LIBRARIES
LIBRARIES
Qt::Core
Qt::CorePrivate
Qt::Gui

View File

@ -12,7 +12,7 @@ qt_internal_add_plugin(QJpegPlugin
SOURCES
main.cpp main.h
qjpeghandler.cpp qjpeghandler_p.h
PUBLIC_LIBRARIES
LIBRARIES
Qt::Core
Qt::CorePrivate
Qt::Gui

View File

@ -15,12 +15,11 @@ qt_internal_add_plugin(QComposePlatformInputContextPlugin
qcomposeplatforminputcontext.cpp qcomposeplatforminputcontext.h
qcomposeplatforminputcontextmain.cpp
LIBRARIES
XKB::XKB
PUBLIC_LIBRARIES
Qt::Core
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
XKB::XKB
)
#### Keys ignored in scope 1:.:.:compose.pro:<TRUE>:

View File

@ -16,12 +16,11 @@ qt_internal_add_plugin(QIbusPlatformInputContextPlugin
qibusproxyportal.cpp qibusproxyportal.h
qibustypes.cpp qibustypes.h
LIBRARIES
XKB::XKB
PUBLIC_LIBRARIES
Qt::Core
Qt::DBus
Qt::Gui
Qt::GuiPrivate
XKB::XKB
)
#### Keys ignored in scope 1:.:.:ibus.pro:<TRUE>:

View File

@ -46,7 +46,7 @@ qt_internal_add_plugin(QAndroidIntegrationPlugin
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}
${QT_SOURCE_TREE}/src/3rdparty/android
PUBLIC_LIBRARIES
LIBRARIES
EGL::EGL
Qt::Core
Qt::CorePrivate

View File

@ -50,7 +50,7 @@ qt_internal_add_plugin(QCocoaIntegrationPlugin
qcocoafontdialoghelper.h qcocoafontdialoghelper.mm
DEFINES
QT_NO_FOREACH
PUBLIC_LIBRARIES
LIBRARIES
${FWAppKit}
${FWCarbon}
${FWCoreServices}

View File

@ -50,27 +50,26 @@ qt_internal_add_plugin(QWindowsDirect2DIntegrationPlugin
INCLUDE_DIRECTORIES
../windows
LIBRARIES
advapi32
d2d1 # special case
dwrite # special case
gdi32
ole32
shell32
user32
winmm
PUBLIC_LIBRARIES
Qt::Core
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
advapi32
d2d1 # special case
d3d11
dwmapi
dwrite # special case
dxgi
dxguid
gdi32
imm32
ole32
oleaut32
shell32
shlwapi
user32
version
winmm
winspool
wtsapi32
)
@ -102,12 +101,12 @@ qt_internal_add_resource(QWindowsDirect2DIntegrationPlugin "openglblacklists"
# PLUGIN_EXTENDS = "-"
qt_internal_extend_target(QWindowsDirect2DIntegrationPlugin CONDITION QT_FEATURE_opengl AND NOT QT_FEATURE_dynamicgl
PUBLIC_LIBRARIES
LIBRARIES
opengl32
)
qt_internal_extend_target(QWindowsDirect2DIntegrationPlugin CONDITION MINGW
PUBLIC_LIBRARIES
LIBRARIES
uuid
)
@ -272,7 +271,7 @@ qt_internal_extend_target(QWindowsDirect2DIntegrationPlugin CONDITION QT_FEATURE
)
qt_internal_extend_target(QWindowsDirect2DIntegrationPlugin CONDITION MINGW AND QT_FEATURE_accessibility
PUBLIC_LIBRARIES
LIBRARIES
uuid
)

View File

@ -23,7 +23,7 @@ qt_internal_add_plugin(QDirectFbIntegrationPlugin
qdirectfbintegration.cpp qdirectfbintegration.h
qdirectfbscreen.cpp qdirectfbscreen.h
qdirectfbwindow.cpp qdirectfbwindow.h
PUBLIC_LIBRARIES
LIBRARIES
PkgConfig::DirectFB
EGL::EGL # special case
Qt::Core

View File

@ -102,7 +102,7 @@ qt_internal_add_plugin(QEglFSIntegrationPlugin
qeglfsmain.cpp
DEFINES
QT_EGL_NO_X11
PUBLIC_LIBRARIES
LIBRARIES
Qt::CorePrivate # special case
Qt::EglFSDeviceIntegrationPrivate
EGL::EGL # special case

View File

@ -27,7 +27,7 @@ qt_internal_add_plugin(QIOSIntegrationPlugin
qioswindow.h qioswindow.mm
quiaccessibilityelement.h quiaccessibilityelement.mm
quiview.h quiview.mm
PUBLIC_LIBRARIES
LIBRARIES
${FWAudioToolbox}
${FWFoundation}
${FWMetal}
@ -47,7 +47,7 @@ qt_disable_apple_app_extension_api_only(QIOSIntegrationPlugin)
#####################################################################
qt_internal_extend_target(QIOSIntegrationPlugin CONDITION QT_FEATURE_opengl
PUBLIC_LIBRARIES
LIBRARIES
Qt::OpenGLPrivate
)
@ -59,7 +59,7 @@ qt_internal_extend_target(QIOSIntegrationPlugin CONDITION NOT TVOS
qiosmenu.h qiosmenu.mm
qiosmessagedialog.h qiosmessagedialog.mm
qiostextinputoverlay.h qiostextinputoverlay.mm
PUBLIC_LIBRARIES
LIBRARIES
${FWAssetsLibrary}
)

View File

@ -13,7 +13,7 @@ qt_internal_add_plugin(QIosOptionalPlugin_NSPhotoLibrary
qiosfileengineassetslibrary.h qiosfileengineassetslibrary.mm
qiosfileenginefactory.h
qiosimagepickercontroller.h qiosimagepickercontroller.mm
PUBLIC_LIBRARIES
LIBRARIES
${FWAssetsLibrary}
${FWFoundation}
${FWUIKit}

View File

@ -14,7 +14,7 @@ qt_internal_add_plugin(QLinuxFbIntegrationPlugin
qlinuxfbscreen.cpp qlinuxfbscreen.h
DEFINES
QT_NO_FOREACH
PUBLIC_LIBRARIES
LIBRARIES
Qt::Core
Qt::CorePrivate
Qt::FbSupportPrivate
@ -29,14 +29,14 @@ qt_internal_add_plugin(QLinuxFbIntegrationPlugin
#####################################################################
qt_internal_extend_target(QLinuxFbIntegrationPlugin CONDITION TARGET Qt::InputSupportPrivate
PUBLIC_LIBRARIES
LIBRARIES
Qt::InputSupportPrivate
)
qt_internal_extend_target(QLinuxFbIntegrationPlugin CONDITION TARGET Qt::KmsSupportPrivate
SOURCES
qlinuxfbdrmscreen.cpp qlinuxfbdrmscreen.h
PUBLIC_LIBRARIES
LIBRARIES
Qt::KmsSupportPrivate
)

View File

@ -16,7 +16,7 @@ qt_internal_add_plugin(QMinimalIntegrationPlugin
qminimalintegration.cpp qminimalintegration.h
DEFINES
QT_NO_FOREACH
PUBLIC_LIBRARIES
LIBRARIES
Qt::Core
Qt::CorePrivate
Qt::Gui

View File

@ -16,7 +16,7 @@ qt_internal_add_plugin(QMinimalEglIntegrationPlugin
qminimaleglwindow.cpp qminimaleglwindow.h
DEFINES
QT_EGL_NO_X11
PUBLIC_LIBRARIES
LIBRARIES
Qt::Core
Qt::CorePrivate
Qt::Gui
@ -33,7 +33,7 @@ qt_internal_add_plugin(QMinimalEglIntegrationPlugin
qt_internal_extend_target(QMinimalEglIntegrationPlugin CONDITION QT_FEATURE_opengl
SOURCES
qminimaleglbackingstore.cpp qminimaleglbackingstore.h
PUBLIC_LIBRARIES
LIBRARIES
Qt::OpenGL
)

View File

@ -15,7 +15,7 @@ qt_internal_add_plugin(QOffscreenIntegrationPlugin
qoffscreenwindow.cpp qoffscreenwindow.h
DEFINES
QT_NO_FOREACH
PUBLIC_LIBRARIES
LIBRARIES
Qt::Core
Qt::CorePrivate
Qt::Gui

View File

@ -16,7 +16,7 @@ qt_internal_add_plugin(QVncIntegrationPlugin
qvncscreen.cpp qvncscreen.h
DEFINES
QT_NO_FOREACH
PUBLIC_LIBRARIES
LIBRARIES
Qt::Core
Qt::CorePrivate
Qt::FbSupportPrivate
@ -32,7 +32,7 @@ qt_internal_add_plugin(QVncIntegrationPlugin
#####################################################################
qt_internal_extend_target(QVncIntegrationPlugin CONDITION TARGET Qt::InputSupportPrivate
PUBLIC_LIBRARIES
LIBRARIES
Qt::InputSupportPrivate
)

View File

@ -43,21 +43,20 @@ qt_internal_add_plugin(QWindowsIntegrationPlugin
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}
LIBRARIES
advapi32
gdi32
ole32
shell32
user32
winmm
PUBLIC_LIBRARIES
Qt::Core
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
advapi32
dwmapi
gdi32
imm32
ole32
oleaut32
shell32
shlwapi
user32
winmm
winspool
wtsapi32
)
@ -88,7 +87,7 @@ qt_internal_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_opengl
SOURCES
qwindowsglcontext.cpp qwindowsglcontext.h
qwindowsopenglcontext.h
PUBLIC_LIBRARIES
LIBRARIES
Qt::OpenGLPrivate
)
@ -96,12 +95,12 @@ qt_internal_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_opengl
# PLUGIN_EXTENDS = "-"
qt_internal_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_opengl AND NOT QT_FEATURE_dynamicgl
PUBLIC_LIBRARIES
LIBRARIES
opengl32
)
qt_internal_extend_target(QWindowsIntegrationPlugin CONDITION MINGW
PUBLIC_LIBRARIES
LIBRARIES
uuid
)
@ -195,7 +194,7 @@ qt_internal_extend_target(QWindowsIntegrationPlugin CONDITION QT_FEATURE_accessi
)
qt_internal_extend_target(QWindowsIntegrationPlugin CONDITION MINGW AND QT_FEATURE_accessibility
PUBLIC_LIBRARIES
LIBRARIES
uuid
)

View File

@ -168,7 +168,7 @@ qt_internal_add_plugin(QXcbIntegrationPlugin
qxcbmain.cpp
DEFINES
QT_NO_FOREACH
PUBLIC_LIBRARIES
LIBRARIES
Qt::CorePrivate
Qt::GuiPrivate
Qt::XcbQpaPrivate

View File

@ -20,7 +20,7 @@ qt_internal_add_plugin(QXcbEglIntegrationPlugin
INCLUDE_DIRECTORIES
..
../..
PUBLIC_LIBRARIES
LIBRARIES
Qt::Core
Qt::CorePrivate
Qt::Gui

View File

@ -18,7 +18,7 @@ qt_internal_add_plugin(QXcbGlxIntegrationPlugin
INCLUDE_DIRECTORIES
..
../..
PUBLIC_LIBRARIES
LIBRARIES
Qt::Core
Qt::CorePrivate
Qt::Gui
@ -30,12 +30,12 @@ qt_internal_add_plugin(QXcbGlxIntegrationPlugin
#####################################################################
qt_internal_extend_target(QXcbGlxIntegrationPlugin CONDITION QT_FEATURE_xcb_glx
PUBLIC_LIBRARIES
LIBRARIES
XCB::GLX
)
qt_internal_extend_target(QXcbGlxIntegrationPlugin
CONDITION QT_FEATURE_dlopen AND QT_BUILD_SHARED_LIBS
PUBLIC_LIBRARIES
LIBRARIES
${CMAKE_DL_LIBS}
)

View File

@ -19,13 +19,12 @@ qt_internal_add_plugin(QGtk3ThemePlugin
DEFINES
GDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_6
LIBRARIES # special case
X11::X11 # special case
PUBLIC_LIBRARIES
PkgConfig::GTK3
Qt::Core
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
X11::X11 # special case
)
#### Keys ignored in scope 1:.:.:gtk3.pro:<TRUE>:

View File

@ -12,7 +12,7 @@ qt_internal_add_plugin(QXdgDesktopPortalThemePlugin
main.cpp
qxdgdesktopportalfiledialog.cpp qxdgdesktopportalfiledialog_p.h
qxdgdesktopportaltheme.cpp qxdgdesktopportaltheme.h
PUBLIC_LIBRARIES
LIBRARIES
Qt::Core
Qt::CorePrivate
Qt::DBus

View File

@ -18,7 +18,6 @@ qt_internal_add_plugin(QCupsPrinterSupportPlugin
../../../printsupport/kernel
LIBRARIES
Cups::Cups
PUBLIC_LIBRARIES
Qt::Core
Qt::CorePrivate
Qt::Gui

View File

@ -13,7 +13,7 @@ qt_internal_add_plugin(QDB2DriverPlugin
DEFINES
QT_NO_CAST_FROM_ASCII
QT_NO_CAST_TO_ASCII
PUBLIC_LIBRARIES
LIBRARIES
DB2::DB2
Qt::Core
Qt::CorePrivate

View File

@ -7,7 +7,7 @@ qt_internal_add_plugin(QIBaseDriverPlugin
DEFINES
QT_NO_CAST_FROM_ASCII
QT_NO_CAST_TO_ASCII
PUBLIC_LIBRARIES
LIBRARIES
Interbase::Interbase
Qt::Core
Qt::CorePrivate

View File

@ -13,7 +13,7 @@ qt_internal_add_plugin(QMYSQLDriverPlugin
DEFINES
QT_NO_CAST_FROM_ASCII
QT_NO_CAST_TO_ASCII
PUBLIC_LIBRARIES
LIBRARIES
MySQL::MySQL
Qt::Core
Qt::CorePrivate

View File

@ -13,7 +13,7 @@ qt_internal_add_plugin(QOCIDriverPlugin
DEFINES
QT_NO_CAST_FROM_ASCII
QT_NO_CAST_TO_ASCII
PUBLIC_LIBRARIES
LIBRARIES
Oracle::OCI
Qt::Core
Qt::CorePrivate

View File

@ -15,7 +15,7 @@ qt_internal_add_plugin(QODBCDriverPlugin
DEFINES
QT_NO_CAST_FROM_ASCII
QT_NO_CAST_TO_ASCII
PUBLIC_LIBRARIES
LIBRARIES
ODBC::ODBC
Qt::Core
Qt::CorePrivate

View File

@ -15,7 +15,7 @@ qt_internal_add_plugin(QPSQLDriverPlugin
DEFINES
QT_NO_CAST_FROM_ASCII
QT_NO_CAST_TO_ASCII
PUBLIC_LIBRARIES
LIBRARIES
PostgreSQL::PostgreSQL
Qt::Core
Qt::CorePrivate

View File

@ -13,7 +13,7 @@ qt_internal_add_plugin(QSQLiteDriverPlugin
DEFINES
QT_NO_CAST_FROM_ASCII
QT_NO_CAST_TO_ASCII
PUBLIC_LIBRARIES
LIBRARIES
Qt::Core
Qt::CorePrivate
Qt::SqlPrivate
@ -27,7 +27,7 @@ qt_internal_add_plugin(QSQLiteDriverPlugin
#####################################################################
qt_internal_extend_target(QSQLiteDriverPlugin CONDITION QT_FEATURE_system_sqlite
PUBLIC_LIBRARIES
LIBRARIES
SQLite::SQLite3
)
@ -79,7 +79,7 @@ qt_internal_extend_target(QSQLiteDriverPlugin CONDITION UNIX AND NOT QT_FEATURE_
)
qt_internal_extend_target(QSQLiteDriverPlugin CONDITION QT_FEATURE_dlopen AND NOT QT_FEATURE_system_sqlite
PUBLIC_LIBRARIES
LIBRARIES
${CMAKE_DL_LIBS}
)

View File

@ -10,7 +10,7 @@ qt_internal_add_plugin(QAndroidStylePlugin
SOURCES
main.cpp
qandroidstyle.cpp qandroidstyle_p.h
PUBLIC_LIBRARIES
LIBRARIES
Qt::Core
Qt::Gui
Qt::WidgetsPrivate

View File

@ -13,7 +13,6 @@ qt_internal_add_plugin(QMacStylePlugin
qmacstyle_mac_p_p.h
LIBRARIES
${FWAppKit}
PUBLIC_LIBRARIES
Qt::Core
Qt::Gui
Qt::WidgetsPrivate

View File

@ -17,7 +17,6 @@ qt_internal_add_plugin(QWindowsVistaStylePlugin
gdi32
user32
uxtheme
PUBLIC_LIBRARIES
Qt::Core
Qt::Gui
Qt::WidgetsPrivate