diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.5) -set(PIM_VERSION "5.14.41") +set(PIM_VERSION "5.14.42") project(KontactInterface VERSION ${PIM_VERSION}) @@ -20,7 +20,7 @@ include(ECMSetupVersion) include(FeatureSummary) include(ECMQtDeclareLoggingCategory) - +include(ECMSetupQtPluginMacroNames) @@ -35,6 +35,15 @@ SOVERSION 5 ) +ecm_setup_qtplugin_macro_names( + JSON_NONE + EXPORT_KONTACT_PLUGIN + JSON_ARG3 + EXPORT_KONTACT_PLUGIN_WITH_JSON + CONFIG_CODE_VARIABLE + PACKAGE_SETUP_AUTOMOC_VARIABLES +) + ########### Find packages ########### find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS CoreAddons diff --git a/KF5KontactInterfaceConfig.cmake.in b/KF5KontactInterfaceConfig.cmake.in --- a/KF5KontactInterfaceConfig.cmake.in +++ b/KF5KontactInterfaceConfig.cmake.in @@ -2,11 +2,6 @@ include(CMakeFindDependencyMacro) find_dependency(KF5Parts "@KF5_MIN_VERSION@") -if(NOT CMAKE_VERSION VERSION_LESS "3.10.0") - # CMake 3.9+ warns about automoc on files without Q_OBJECT, and doesn't know about other macros. - # 3.10+ lets us provide more macro names that require automoc. - # KF5 >= 5.42 takes care itself of adding its macros in its cmake config files - list(APPEND CMAKE_AUTOMOC_MACRO_NAMES "EXPORT_KONTACT_PLUGIN") -endif() +@PACKAGE_SETUP_AUTOMOC_VARIABLES@ include("${CMAKE_CURRENT_LIST_DIR}/KF5KontactInterfaceTargets.cmake") diff --git a/src/plugin.h b/src/plugin.h --- a/src/plugin.h +++ b/src/plugin.h @@ -46,7 +46,12 @@ } /** - Exports Kontact plugin. + Increase this version number whenever you make a change in the API. + */ +#define KONTACT_PLUGIN_VERSION 10 + +/** + Exports Kontact plugin. Deprecated in favour of EXPORT_KONTACT_PLUGIN_WITH_JSON */ #define EXPORT_KONTACT_PLUGIN( pluginclass, pluginname ) \ class Instance \ @@ -59,9 +64,20 @@ ( QString(), Instance::createInstance ); ) /** - Increase this version number whenever you make a change in the API. + Exports Kontact plugin. + @param pluginclass the class to instanciate (must derive from KontactInterface::Plugin + @param jsonFile filename of the JSON file, generated from a .desktop file */ -#define KONTACT_PLUGIN_VERSION 10 +#define EXPORT_KONTACT_PLUGIN_WITH_JSON( pluginclass, jsonFile ) \ + class Instance \ + { \ + public: \ + static QObject *createInstance( QWidget *, QObject *parent, const QVariantList &list ) \ + { return new pluginclass( static_cast( parent ), list ); } \ + }; \ + K_PLUGIN_FACTORY_WITH_JSON( KontactPluginFactory, jsonFile, registerPlugin< pluginclass > \ + ( QString(), Instance::createInstance ); ) \ + K_EXPORT_PLUGIN_VERSION(KONTACT_PLUGIN_VERSION) namespace KontactInterface {