diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,7 @@ include(ECMGenerateHeaders) include(ECMQtDeclareLoggingCategory) include(ECMAddQch) +include(ECMSetupQtPluginMacroNames) include(KDEInstallDirs) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) @@ -29,27 +30,15 @@ set(REQUIRED_QT_VERSION 5.7.0) find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Core) -# TODO: create ECM macro for automoc & json things -set(KCoreAddons_AUTOMOC_MACRO_NAMES "K_PLUGIN_FACTORY_WITH_JSON" "K_PLUGIN_FACTORY" "K_PLUGIN_CLASS_WITH_JSON") -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. - list(APPEND CMAKE_AUTOMOC_MACRO_NAMES ${KCoreAddons_AUTOMOC_MACRO_NAMES}) -endif() -set(KCoreAddons_AUTOMOC_MACRO_NAMES_WITH_JSON_ARG2 "K_PLUGIN_FACTORY_WITH_JSON" "K_PLUGIN_CLASS_WITH_JSON") -if(NOT CMAKE_VERSION VERSION_LESS "3.9.0") - # CMake's automoc needs help to find names of plugin metadata files in case Q_PLUGIN_METADATA - # is indirectly used via other C++ preprocessor macros - # 3.9+ lets us provide some filter rule pairs (keyword, regexp) to match the names of such files - # in the plain text of the sources. See AUTOMOC_DEPEND_FILTERS docs for details. - foreach(macro_name ${KCoreAddons_AUTOMOC_MACRO_NAMES_WITH_JSON_ARG2}) - list(APPEND CMAKE_AUTOMOC_DEPEND_FILTERS - "${macro_name}" - "[\n^][ \t]*${macro_name}[ \t\n]*\\([^,]*,[ \t\n]*\"([^\"]+)\"" - ) - endforeach() -endif() - +ecm_setup_qtplugin_macro_names( + JSON_NONE + "K_PLUGIN_FACTORY" + JSON_ARG2 + "K_PLUGIN_FACTORY_WITH_JSON" + "K_PLUGIN_CLASS_WITH_JSON" + CONFIG_CODE_VARIABLE + PACKAGE_SETUP_AUTOMOC_VARIABLES +) find_package(Threads) diff --git a/KF5CoreAddonsConfig.cmake.in b/KF5CoreAddonsConfig.cmake.in --- a/KF5CoreAddonsConfig.cmake.in +++ b/KF5CoreAddonsConfig.cmake.in @@ -3,21 +3,7 @@ include(CMakeFindDependencyMacro) find_dependency(Qt5Core @REQUIRED_QT_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. - list(APPEND CMAKE_AUTOMOC_MACRO_NAMES @KCoreAddons_AUTOMOC_MACRO_NAMES@) -endif() -if(NOT CMAKE_VERSION VERSION_LESS "3.9.0") - foreach(macro_name @KCoreAddons_AUTOMOC_MACRO_NAMES_WITH_JSON_ARG2@) - # tell automoc how to find names of plugin metadata files - list(APPEND CMAKE_AUTOMOC_DEPEND_FILTERS - "${macro_name}" - "[\n^][ \t]*${macro_name}[ \t\n]*\\([^,]*,[ \t\n]*\"([^\"]+)\"" - ) - endforeach() -endif() +@PACKAGE_SETUP_AUTOMOC_VARIABLES@ if(CMAKE_CROSSCOMPILING AND KF5_HOST_TOOLING) find_file(TARGETSFILE KF5CoreAddons/KF5CoreAddonsToolingTargets.cmake