From c1dbb78eae10a63cc915771bc57ce00cd21cf6ac Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Fri, 19 May 2017 18:10:54 +0200 Subject: [PATCH] [FEATURE] Option to build & install QCH file with the public API dox Using the new extra-cmake-modules module ECMAddQch (since 5.36.0) this adds the option to automatically build and install a file in QCH format with the docs about the public API, which then can be used e.g. in Qt Assistant, Qt Creator or KDevelop. Additionally the installed cmake config files will be extended with a target KF5ItemModels_QCH containing information about how to "link" into the generated QCH file, which then can be used in the cmake build system of other libraries building on this library, by simply listing this target in "LINK_QCHS" of their ecm_add_qch() usage. And a respective doxygen tag file with all the metadata about the generated QCH file and used for the "linking" will be created and installed. Pass -DBUILD_QCH=ON to cmake to enable this. --- CMakeLists.txt | 13 +++++++++++++ KF5ItemModelsConfig.cmake.in | 2 +- src/CMakeLists.txt | 21 +++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a4eb3d..b298a5d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,10 @@ include(GenerateExportHeader) include(ECMSetupVersion) include(ECMGenerateHeaders) +include(ECMAddQch) + +option(BUILD_QCH "Build API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)" OFF) +add_feature_info(QCH ${BUILD_QCH} "API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)") ecm_setup_version(PROJECT VARIABLE_PREFIX KITEMMODELS VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kitemmodels_version.h" @@ -40,6 +44,15 @@ endif() # create a Config.cmake and a ConfigVersion.cmake file and install them set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5ItemModels") +if (BUILD_QCH) + ecm_install_qch_export( + TARGETS KF5ItemModels_QCH + FILE KF5ItemModelsQCHTargets.cmake + DESTINATION "${CMAKECONFIG_INSTALL_DIR}" + ) + set(PACKAGE_INCLUDE_QCHTARGETS "include(\"\${CMAKE_CURRENT_LIST_DIR}/KF5ItemModelsQCHTargets.cmake\")") +endif() + include(CMakePackageConfigHelpers) configure_package_config_file( diff --git a/KF5ItemModelsConfig.cmake.in b/KF5ItemModelsConfig.cmake.in index 819f1e2..f2bc3e4 100644 --- a/KF5ItemModelsConfig.cmake.in +++ b/KF5ItemModelsConfig.cmake.in @@ -5,4 +5,4 @@ find_dependency(Qt5Core @REQUIRED_QT_VERSION@) include("${CMAKE_CURRENT_LIST_DIR}/KF5ItemModelsTargets.cmake") - +@PACKAGE_INCLUDE_QCHTARGETS@ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d4c56c9..641dd1d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -73,6 +73,27 @@ install(FILES DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/KItemModels COMPONENT Devel ) +if(BUILD_QCH) + ecm_add_qch( + KF5ItemModels_QCH + NAME KItemModels + BASE_NAME KF5ItemModels + VERSION ${KF5_VERSION} + ORG_DOMAIN org.kde + SOURCES # using only public headers, to cover only public API + ${KItemModels_HEADERS} + MD_MAINPAGE "${CMAKE_SOURCE_DIR}/README.md" + IMAGE_DIRS "${CMAKE_SOURCE_DIR}/docs/pics" + LINK_QCHS + Qt5Core_QCH + BLANK_MACROS + KITEMMODELS_EXPORT + TAGFILE_INSTALL_DESTINATION ${KDE_INSTALL_QTQCHDIR} + QCH_INSTALL_DESTINATION ${KDE_INSTALL_QTQCHDIR} + COMPONENT Devel + ) +endif() + include(ECMGeneratePriFile) ecm_generate_pri_file(BASE_NAME KItemModels LIB_NAME KF5ItemModels DEPS "core" FILENAME_VAR PRI_FILENAME INCLUDE_INSTALL_DIR ${KDE_INSTALL_INCLUDEDIR_KF5}/KItemModels) install(FILES ${PRI_FILENAME} DESTINATION ${ECM_MKSPECS_INSTALL_DIR})