From 37bf29d57d6b0620d71f4993e300eda87b433989 Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Wed, 8 Apr 2020 02:33:25 +0200 Subject: [PATCH] Use ecm_setup_qtplugin_macro_names Avoids all the explicit boilerplate needed, ensures the dependency on the JSON file ia also set and allows simple export of the setup in the installed CMake config file, so other projects importing the config file have the respective CMake macros set as recommended. Test Plan: Still builds as before. Touch a plugin metadata JSON file now triggers a moc rerun. CMake config file contains setup of variables. --- CMakeLists.txt | 23 ++++++----------------- Okular5Config.cmake.in | 20 +------------------- 2 files changed, 7 insertions(+), 36 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4998b13f2..7f466909c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,6 +43,7 @@ include(KDECMakeSettings) include(ECMAddTests) include(ECMAddAppIcon) include(CMakePackageConfigHelpers) +include(ECMSetupQtPluginMacroNames) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -65,24 +66,12 @@ if(ANDROID) find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED COMPONENTS AndroidExtras) endif() -# Replace with ECMSetupQtPluginMacroNames once depending on ECM >= 5.45 -# incl. passing same code generated by var into Okular5Config.cmake.in -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 "OKULAR_EXPORT_PLUGIN") -endif() - -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. - list(APPEND CMAKE_AUTOMOC_DEPEND_FILTERS +ecm_setup_qtplugin_macro_names( + JSON_ARG2 "OKULAR_EXPORT_PLUGIN" - "[\n^][ \t]*OKULAR_EXPORT_PLUGIN[ \t\n]*\\([^,]*,[ \t\n]*\"([^\"]+)\"" - ) -endif() + CONFIG_CODE_VARIABLE + PACKAGE_SETUP_AUTOMOC_VARIABLES +) set(optionalComponents) if (ANDROID) diff --git a/Okular5Config.cmake.in b/Okular5Config.cmake.in index 98fed1e1f..6f9046d9c 100644 --- a/Okular5Config.cmake.in +++ b/Okular5Config.cmake.in @@ -9,24 +9,6 @@ find_dependency(KF5CoreAddons @KF5_REQUIRED_VERSION@) find_dependency(KF5Config @KF5_REQUIRED_VERSION@) find_dependency(KF5XmlGui @KF5_REQUIRED_VERSION@) -#################################################################################### -# CMAKE_AUTOMOC - -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 OKULAR_EXPORT_PLUGIN) -endif() - -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. - list(APPEND CMAKE_AUTOMOC_DEPEND_FILTERS - "OKULAR_EXPORT_PLUGIN" - "[\n^][ \t]*OKULAR_EXPORT_PLUGIN[ \t\n]*\\([^,]*,[ \t\n]*\"([^\"]+)\"" - ) -endif() +@PACKAGE_SETUP_AUTOMOC_VARIABLES@ include("${CMAKE_CURRENT_LIST_DIR}/Okular5Targets.cmake")