From 6fbeef4c6b2323fc4b7856520c0f38f8139c9c54 Mon Sep 17 00:00:00 2001 From: Leander Beernaert Date: Tue, 21 Apr 2020 13:28:57 +0200 Subject: CMake: Add qt6_add_plugin public API This patch adds a publicly callable qt6_add_plugin() API to create plugins. This API is meant to cover cases such as the plugandpaint example. This patch also renames qt_add_plugin to qt_internal_add_plugin in order to avoid clashes with the public API. To avoid breaking the existing projects, a compatibility wrapper function is enabled by default unless QT_DISABLE_QT_ADD_PLUGIN_COMPATIBILITY is specified. Fixes: QTBUG-82961 Change-Id: If5b564a8406c90434f1bdad0b8df76d3e6626b5f Reviewed-by: Alexandru Croitor --- examples/widgets/tools/CMakeLists.txt | 4 +--- .../tools/plugandpaint/plugins/basictools/.prev_CMakeLists.txt | 3 ++- examples/widgets/tools/plugandpaint/plugins/basictools/CMakeLists.txt | 3 ++- .../tools/plugandpaint/plugins/extrafilters/.prev_CMakeLists.txt | 3 ++- .../widgets/tools/plugandpaint/plugins/extrafilters/CMakeLists.txt | 3 ++- 5 files changed, 9 insertions(+), 7 deletions(-) (limited to 'examples/widgets') diff --git a/examples/widgets/tools/CMakeLists.txt b/examples/widgets/tools/CMakeLists.txt index 3346cafe09..80c8f43007 100644 --- a/examples/widgets/tools/CMakeLists.txt +++ b/examples/widgets/tools/CMakeLists.txt @@ -15,7 +15,5 @@ add_subdirectory(undoframework) if(QT_FEATURE_library) # special case add_subdirectory(echoplugin) - # FIXME: Currently broken # special case - # Fails to link (ld: error: undefined symbol: qt_static_plugin_BasicToolsPlugin()) # special case - #add_subdirectory(plugandpaint) # special case + add_subdirectory(plugandpaint) # special case endif() diff --git a/examples/widgets/tools/plugandpaint/plugins/basictools/.prev_CMakeLists.txt b/examples/widgets/tools/plugandpaint/plugins/basictools/.prev_CMakeLists.txt index fefa30e2a4..76474c282b 100644 --- a/examples/widgets/tools/plugandpaint/plugins/basictools/.prev_CMakeLists.txt +++ b/examples/widgets/tools/plugandpaint/plugins/basictools/.prev_CMakeLists.txt @@ -15,7 +15,8 @@ find_package(Qt6 COMPONENTS Core) find_package(Qt6 COMPONENTS Gui) find_package(Qt6 COMPONENTS Widgets) -add_library(pnp_basictools MODULE +qt6_add_plugin(pnp_basictools STATIC) +target_sources(pnp_basictools PRIVATE basictoolsplugin.cpp basictoolsplugin.h ) target_include_directories(pnp_basictools PUBLIC diff --git a/examples/widgets/tools/plugandpaint/plugins/basictools/CMakeLists.txt b/examples/widgets/tools/plugandpaint/plugins/basictools/CMakeLists.txt index fefa30e2a4..b0a752718f 100644 --- a/examples/widgets/tools/plugandpaint/plugins/basictools/CMakeLists.txt +++ b/examples/widgets/tools/plugandpaint/plugins/basictools/CMakeLists.txt @@ -15,7 +15,8 @@ find_package(Qt6 COMPONENTS Core) find_package(Qt6 COMPONENTS Gui) find_package(Qt6 COMPONENTS Widgets) -add_library(pnp_basictools MODULE +qt_add_plugin(pnp_basictools STATIC) +target_sources(pnp_basictools PRIVATE basictoolsplugin.cpp basictoolsplugin.h ) target_include_directories(pnp_basictools PUBLIC diff --git a/examples/widgets/tools/plugandpaint/plugins/extrafilters/.prev_CMakeLists.txt b/examples/widgets/tools/plugandpaint/plugins/extrafilters/.prev_CMakeLists.txt index 2f689893bb..57f37843b8 100644 --- a/examples/widgets/tools/plugandpaint/plugins/extrafilters/.prev_CMakeLists.txt +++ b/examples/widgets/tools/plugandpaint/plugins/extrafilters/.prev_CMakeLists.txt @@ -15,7 +15,8 @@ find_package(Qt6 COMPONENTS Core) find_package(Qt6 COMPONENTS Gui) find_package(Qt6 COMPONENTS Widgets) -add_library(pnp_extrafilters MODULE +qt_add_plugin(pnp_extrafilters) +target_sources(pnp_extrafilters PRIVATE extrafiltersplugin.cpp extrafiltersplugin.h ) target_include_directories(pnp_extrafilters PUBLIC diff --git a/examples/widgets/tools/plugandpaint/plugins/extrafilters/CMakeLists.txt b/examples/widgets/tools/plugandpaint/plugins/extrafilters/CMakeLists.txt index 2f689893bb..57f37843b8 100644 --- a/examples/widgets/tools/plugandpaint/plugins/extrafilters/CMakeLists.txt +++ b/examples/widgets/tools/plugandpaint/plugins/extrafilters/CMakeLists.txt @@ -15,7 +15,8 @@ find_package(Qt6 COMPONENTS Core) find_package(Qt6 COMPONENTS Gui) find_package(Qt6 COMPONENTS Widgets) -add_library(pnp_extrafilters MODULE +qt_add_plugin(pnp_extrafilters) +target_sources(pnp_extrafilters PRIVATE extrafiltersplugin.cpp extrafiltersplugin.h ) target_include_directories(pnp_extrafilters PUBLIC -- cgit v1.2.3