Warning, /libraries/kdb/cmake/modules/KDbAddQCH.cmake is written in an unsupported language. File is not indexed.

0001 #.rst:
0002 # KDbAddQCH
0003 # ------------------
0004 #
0005 # This module provides the ``kdb_add_qch`` function for generating API
0006 # documentation files in the QCH format, and the ``kdb_install_qch_export``
0007 # function for generating and installing exported CMake targets for such
0008 # generated QCH files to enable builds of other software with generation of
0009 # QCH files to create links into the given QCH files.
0010 #
0011 # ::
0012 #
0013 #   kdb_add_qch(<target_name>
0014 #       NAME <name>
0015 #       VERSION <version>
0016 #       QCH_INSTALL_DESTINATION <qchfile_install_path>
0017 #       TAGFILE_INSTALL_DESTINATION <tagsfile_install_path>
0018 #       [BASE_NAME <basename>]
0019 #       [SOURCE_DIRS <dir> [<dir2> [...]]]
0020 #       [SOURCES <file> [<file2> [...]]]
0021 #       |MD_MAINPAGE <md_file>]
0022 #       [IMAGE_DIRS <idir> [<idir2> [...]]]
0023 #       [EXAMPLE_DIRS <edir> [<edir2> [...]]]
0024 #       [ORG_DOMAIN <domain>]
0025 #       [NAMESPACE <namespace>]
0026 #       [LINK_QCHS <qch> [<qch2> [...]]]
0027 #       [LINK_QCHS_VERSIONED <qchv> [<qchv2> [...]]]
0028 #       [BLANK_MACROS <macro> [<macro2> [...]]]
0029 #       [CONFIG_TEMPLATE <configtemplate_file>]
0030 #       [VERBOSE]
0031 #   )
0032 #
0033 # This macro adds a target called <target_name> for the creation of an API
0034 # documentation manual in the QCH format from the given sources.
0035 # It currently uses doxygen, future versions might optionally also allow other
0036 # tools.
0037 # Next to the QCH file the target will generate a corresponding doxygen tag
0038 # file, which enables creating links from other documentation into the
0039 # generated QCH file.
0040 #
0041 # If the required tools are not found, the macro will skip creation of the
0042 # target and only emit a warning, so the use of the macro can be introduced
0043 # without requiring anyone to also have the needed tools present at that time.
0044 # This behaviour might change in future versions to result in a fail instead.
0045 # It is recommended to make the use of this macro optional, by depending
0046 # the call to ``kdb_add_qch()`` on a CMake option being set, with a name like
0047 # ``BUILD_QCH`` and being TRUE by default. This will allow the developers to
0048 # saves resources on normal source development build cycles by setting this
0049 # option to FALSE.
0050 #
0051 # The macro will set the target properties DOXYGEN_TAGFILE, QHP_NAMESPACE,
0052 # QHP_NAMESPACE_VERSIONED and QHP_VIRTUALFOLDER to the respective values, to
0053 # allow other code access to them, e.g. the macro kdb_install_qch_export().
0054 # To enable the use of the target <target_name> as item for LINK_QCHS or
0055 # LINK_QCHS_VERSIONED in further ``kdb_add_qch()`` calls in the current build,
0056 # additionally a target property DOXYGEN_TAGFILE_BUILD is set, with the path
0057 # of the created doxygen tag file in the build dir.
0058 # If existing, ``kdb_add_qch()`` will use this property instead of
0059 # DOXYGEN_TAGFILE for access to the tags file.
0060 #
0061 # NAME specifies the name for the generated documentation.
0062 #
0063 # VERSION specifies the version of the library for which the documentation is
0064 # created.
0065 #
0066 # BASE_NAME specifies the base name for the generated files.
0067 # The default basename is ``<name>``.
0068 #
0069 # SOURCE_DIRS specifies the dirs (incl. subdirs) with the source files for
0070 # which the API documentation should be generated.  Dirs can be relative to
0071 # the current source dir. Dependencies to the files in the dirs are not
0072 # tracked currently, other than with the SOURCES argument. So do not use for
0073 # sources generated during the build.
0074 # Needs to be used when SOURCES or CONFIG_TEMPLATE are not used.
0075 #
0076 # SOURCES specifies the source files for which the API documentation should be
0077 # generated.
0078 # Needs to be used when SOURCE_DIRS or CONFIG_TEMPLATE are not used.
0079 #
0080 # MD_MAINPAGE specifies a file in Markdown format that should be used as main
0081 # page. This page will overrule any ``\mainpage`` command in the included
0082 # sources.
0083 #
0084 # IMAGE_DIRS specifies the dirs which contain images that are included in the
0085 # documentation. Dirs can be relative to the current source dir.
0086 #
0087 # EXAMPLE_DIRS specifies the dirs which contain examples that are included in
0088 # the documentation. Dirs can be relative to the current source dir.
0089 #
0090 # QCH_INSTALL_DESTINATION specifies where the generated QCH file will be
0091 # installed.
0092 #
0093 # TAGFILE_INSTALL_DESTINATION specifies where the generated tag file will be
0094 # installed.
0095 #
0096 # NAMESPACE can be used to set a custom namespace <namespace> of the generated
0097 # QCH file. The namepspace is used as the unique id by QHelpEngine (cmp.
0098 # https://doc.qt.io/qt-5/qthelpproject.html#namespace).
0099 # The default namespace is ``<domain>.<name>``.
0100 # Needs to be used when ORG_DOMAIN is not used.
0101 #
0102 # ORG_DOMAIN can be used to define the organization domain prefix for the
0103 # default namespace of the generated QCH file.
0104 # Needs to be used when NAMESPACE is not used.
0105 #
0106 # LINK_QCHS specifies a list of other QCH targets which should be used for
0107 # creating references to API documenation of code in external libraries.
0108 # For each target <qch> in the list these target properties are expected to be
0109 # defined: DOXYGEN_TAGFILE, QHP_NAMESPACE and QHP_VIRTUALFOLDER.
0110 # If any of these is not existing, <qch> will be ignored.
0111 # Use the macro kdb_install_qch_export for exporting a target with these
0112 # properties with the CMake config of a library.
0113 # Any target <qch> can also be one created before in the same buildsystem by
0114 # another call of ``kdb_add_qch()``.
0115 #
0116 # LINK_QCHS_VERSIONED does basically the same as LINK_QCHS, but binds the links
0117 # to a certain version.
0118 # For each <qchv> in the list these target properties are expected to be
0119 # defined: DOXYGEN_TAGFILE, QHP_NAMESPACE_VERSIONED and QHP_VIRTUALFOLDER.
0120 # If any of these is not existing, <qchv> will be ignored.
0121 # Use the macro kdb_install_qch_export for exporting a target with these
0122 # properties with the CMake config of a library.
0123 # Any <qchv> can also be one created before in the same buildsystem by another
0124 # call of ``kdb_add_qch()``.
0125 #
0126 # BLANK_MACROS specifies a list of C/C++ macro names which should be ignored by
0127 # the API dox generation tool and handled as if they resolve to empty strings.
0128 # Examples are export macros only defined in generated files, so whose
0129 # definition might be not available to the tool.
0130 #
0131 # CONFIG_TEMPLATE specifies a custom cmake template file for the config file
0132 # that is created to control the execution of the API dox generation tool.
0133 # The following CMake variables need to be used:
0134 # ECM_DOXYGENQCH_PERL_EXECUTABLE, ECM_DOXYGENQCH_QHELPGENERATOR_EXECUTABLE,
0135 # ECM_DOXYGENQCH_FILEPATH, ECM_DOXYGENQCH_TAGFILE.
0136 # The following CMake variables can be used:
0137 # ECM_DOXYGENQCH_PROJECTNAME, ECM_DOXYGENQCH_PROJECTVERSION,
0138 # ECM_DOXYGENQCH_VIRTUALFOLDER, ECM_DOXYGENQCH_FULLNAMESPACE,
0139 # ECM_DOXYGENQCH_TAGFILES,
0140 # ECM_DOXYGENQCH_WARN_LOGFILE, ECM_DOXYGENQCH_QUIET.
0141 # There is no guarantue that the other CMake variables currently used in the
0142 # default config file template will also be present with the same semantics
0143 # in future versions of this macro.
0144 #
0145 # VERBOSE tells the API dox generation tool to be more verbose about its
0146 # activity.
0147 #
0148 # Example usage:
0149 #
0150 # .. code-block:: cmake
0151 #
0152 #   kdb_add_qch(
0153 #       MyLib_QCH
0154 #       NAME MyLib
0155 #       VERSION "0.42.0"
0156 #       ORG_DOMAIN org.myorg
0157 #       SOURCE_DIRS
0158 #           src
0159 #       LINK_QCHS
0160 #           Qt5Core_QCH
0161 #           Qt5Xml_QCH
0162 #           Qt5Gui_QCH
0163 #           Qt5Widgets_QCH
0164 #       BLANK_MACROS
0165 #           MyLib_EXPORT
0166 #           MyLib_DEPRECATED
0167 #       TAGFILE_INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/share/docs/tags
0168 #       QCH_INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/share/docs/qch
0169 #   )
0170 #
0171 # Example usage (with two QCH files, second linking first):
0172 #
0173 # .. code-block:: cmake
0174 #
0175 #   kdb_add_qch(
0176 #       MyLib_QCH
0177 #       NAME MyLib
0178 #       VERSION ${MyLib_VERSION}
0179 #       ORG_DOMAIN org.myorg
0180 #       SOURCES ${MyLib_PUBLIC_HEADERS}
0181 #       MD_MAINPAGE src/mylib/README.md
0182 #       LINK_QCHS Qt5Core_QCH
0183 #       TAGFILE_INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/share/docs/tags
0184 #       QCH_INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/share/docs/qch
0185 #   )
0186 #   kdb_add_qch(
0187 #       MyOtherLib_QCH
0188 #       NAME MyOtherLib
0189 #       VERSION ${MyOtherLib_VERSION}
0190 #       ORG_DOMAIN org.myorg
0191 #       SOURCES ${MyOtherLib_PUBLIC_HEADERS}
0192 #       MD_MAINPAGE src/myotherlib/README.md
0193 #       LINK_QCHS Qt5Core_QCH MyLib_QCH
0194 #       TAGFILE_INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/share/docs/tags
0195 #       QCH_INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/share/docs/qch
0196 #   )
0197 #
0198 # ::
0199 #
0200 #   kdb_install_qch_export(
0201 #       TARGETS [<name> [<name2> [...]]]
0202 #       FILE <file>
0203 #       DESTINATION <dest>
0204 #       [COMPONENT <component>}]
0205 #   )
0206 #
0207 # This macro creates and installs a CMake file <file> which exports the given
0208 # QCH targets <name> etc., so they can be picked up by CMake-based builds of
0209 # other software that also generate QCH files (using ``kdb_add_qch()``) and
0210 # which should include links to the QCH files created by the given targets.
0211 # The installed CMake file <file> is expected to be included by the CMake
0212 # config file created for the software the related QCH files are documenting.
0213 #
0214 # TARGETS specifies the QCH targets which should be exported. If a target does
0215 # not exist or does not have all needed properties, a warning will be
0216 # generated and the target skipped.
0217 # This behaviour might change in future versions to result in a fail instead.
0218 #
0219 # FILE specifies the name of the created CMake file, typically with a .cmake
0220 # extension.
0221 #
0222 # DESTINATION specifies the directory on disk to which the file will be
0223 # installed. It usually is the same as the one where the CMake config files
0224 # for this software are installed.
0225 #
0226 # COMPONENT specifies the installation component name with which the
0227 # install rule is associated.
0228 #
0229 # Example usage:
0230 #
0231 # .. code-block:: cmake
0232 #
0233 #   kdb_install_qch_export(
0234 #       TARGETS MyLib_QCH
0235 #       FILE MyLibQCHTargets.cmake
0236 #       DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/cmake/MyLib"
0237 #       COMPONENT Devel
0238 #   )
0239 
0240 #=============================================================================
0241 # Copyright 2016 Friedrich W. H. Kossebau <kossebau@kde.org>
0242 #
0243 # Redistribution and use in source and binary forms, with or without
0244 # modification, are permitted provided that the following conditions
0245 # are met:
0246 #
0247 # 1. Redistributions of source code must retain the copyright
0248 #    notice, this list of conditions and the following disclaimer.
0249 # 2. Redistributions in binary form must reproduce the copyright
0250 #    notice, this list of conditions and the following disclaimer in the
0251 #    documentation and/or other materials provided with the distribution.
0252 # 3. The name of the author may not be used to endorse or promote products
0253 #    derived from this software without specific prior written permission.
0254 #
0255 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
0256 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
0257 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
0258 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
0259 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
0260 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0261 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0262 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0263 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
0264 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0265 
0266 # needed to find helper files
0267 get_filename_component(_module_dir ${CMAKE_CURRENT_LIST_FILE} PATH)
0268 
0269 # Estimate KDB_QTQCH_FULL_INSTALL_DIR
0270 include(KDEInstallDirs) # for KDE_INSTALL_USE_QT_SYS_PATHS & KDE_INSTALL_FULL_DATAROOTDIR
0271 include("${_module_dir}/KDbQueryQmake.cmake")
0272 if(KDE_INSTALL_USE_QT_SYS_PATHS)
0273     query_qmake(qt_docs_dir QT_INSTALL_DOCS)
0274     set(KDB_QTQCH_FULL_INSTALL_DIR "${qt_docs_dir}")
0275 else()
0276     set(KDB_QTQCH_FULL_INSTALL_DIR "${KDE_INSTALL_FULL_DATAROOTDIR}/doc/qch")
0277 endif()
0278 
0279 include(CMakeParseArguments)
0280 
0281 function(kdb_add_qch target_name)
0282     # Parse arguments
0283     set(options VERBOSE)
0284     set(oneValueArgs NAME BASE_NAME QCH_INSTALL_DESTINATION TAGFILE_INSTALL_DESTINATION VERSION NAMESPACE MD_MAINPAGE ORG_DOMAIN CONFIG_TEMPLATE)
0285     set(multiValueArgs SOURCE_DIRS SOURCES IMAGE_DIRS EXAMPLE_DIRS BLANK_MACROS LINK_QCHS LINK_QCHS_VERSIONED)
0286     cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
0287 
0288     # check required args
0289     foreach(_arg_name NAME QCH_INSTALL_DESTINATION TAGFILE_INSTALL_DESTINATION VERSION)
0290         if(NOT DEFINED ARGS_${_arg_name})
0291             message(FATAL_ERROR "${_arg_name} needs to be defined when calling kdb_add_qch")
0292         endif()
0293     endforeach()
0294     if(NOT DEFINED ARGS_SOURCE_DIRS AND NOT DEFINED ARGS_SOURCES AND NOT DEFINED ARGS_CONFIG_TEMPLATE)
0295         message(FATAL_ERROR "SOURCE_DIRS or SOURCES needs to be defined when calling kdb_add_qch")
0296     endif()
0297     if(DEFINED ARGS_SOURCE_DIRS AND DEFINED ARGS_SOURCES)
0298         message(FATAL_ERROR "Either SOURCE_DIRS or SOURCES, not both, needs to be defined when calling kdb_add_qch")
0299     endif()
0300     if(NOT DEFINED ARGS_ORG_DOMAIN AND NOT DEFINED ARGS_NAMESPACE)
0301         message(FATAL_ERROR "ORG_DOMAIN or NAMESPACE needs to be defined when calling kdb_add_qch")
0302     endif()
0303 
0304     # find required tools
0305     # TODO: check with doxygen author if perl is really still required, PERL_PATH seems unused in doxygen
0306     find_package(Perl)
0307     set_package_properties(Perl PROPERTIES
0308         PURPOSE "Needed for API dox QCH file generation"
0309         TYPE OPTIONAL
0310     )
0311     if (NOT DOXYGEN_PATCHED_JSFILESADDED)
0312         set(REQUIRED_DOXYGEN_VERSION 1.8.13)
0313     endif()
0314     find_package(Doxygen ${REQUIRED_DOXYGEN_VERSION})
0315     if (NOT DOXYGEN_FOUND AND NOT DOXYGEN_PATCHED_JSFILESADDED)
0316         set(doxygen_description_addition " (Or older version patched with https://github.com/doxygen/doxygen/commit/bf9415698e53d79b, pass -DDOXYGEN_PATCHED_JSFILESADDED=ON to cmake if patched)")
0317     endif()
0318     set_package_properties(Doxygen PROPERTIES
0319         TYPE OPTIONAL
0320         PURPOSE "Needed for API dox QCH file generation${doxygen_description_addition}"
0321     )
0322     find_package(QHelpGenerator)
0323     set_package_properties(QHelpGenerator PROPERTIES
0324         TYPE OPTIONAL
0325         PURPOSE "Needed for API dox QCH file generation"
0326         DESCRIPTION "Part of Qt5 tools"
0327     )
0328     set(_missing_tools)
0329     if (NOT PERL_FOUND)
0330         list(APPEND _missing_tools "Perl")
0331     endif()
0332     if (NOT DOXYGEN_FOUND)
0333         list(APPEND _missing_tools "Doxygen")
0334     endif()
0335     if (NOT QHelpGenerator_FOUND)
0336         list(APPEND _missing_tools "qhelpgenerator")
0337     endif()
0338 
0339     if (_missing_tools)
0340         message(WARNING "API dox QCH file will not be generated, tools missing: ${_missing_tools}!")
0341     else()
0342         set(ECM_DOXYGENQCH_QHELPGENERATOR_EXECUTABLE ${QHelpGenerator_EXECUTABLE})
0343         # create QCH targets for Qt
0344         # Ideally one day Qt CMake Config files provide these
0345         if(NOT TARGET Qt5Core_QCH)
0346             # get Qt version, if any
0347             find_package(Qt5Core CONFIG QUIET)
0348             # lookup tag files
0349             query_qmake(qt_docs_dir QT_INSTALL_DOCS)
0350             find_path(_qtcoreTagsPath qtcore/qtcore.tags
0351                 PATHS
0352                     ${qt_docs_dir}
0353             )
0354 
0355             if(Qt5Core_FOUND AND _qtcoreTagsPath)
0356                 string(REPLACE "." "" _version ${Qt5Core_VERSION})
0357                 # TODO: properly find each tag file
0358                 # TODO: complete list of Qt modules
0359                 foreach(_module
0360                     Bluetooth Concurrent Core DBus Gui Location Multimedia MultimediaWidgets
0361                     Network Positioning PrintSupport Qml Quick Sensors SerialPort Sql Svg
0362                     WebEngine WebView Widgets Xml XmlPatterns
0363                 )
0364                     string(TOLOWER ${_module} _lowermodule)
0365 
0366                     add_custom_target(Qt5${_module}_QCH)
0367                     set_target_properties(Qt5${_module}_QCH PROPERTIES
0368                         DOXYGEN_TAGFILE         "${_qtcoreTagsPath}/qt${_lowermodule}/qt${_lowermodule}.tags"
0369                         QHP_NAMESPACE           "org.qt-project.qt${_lowermodule}"
0370                         QHP_NAMESPACE_VERSIONED "org.qt-project.qt${_lowermodule}.${_version}"
0371                         QHP_VIRTUALFOLDER       "qt${_lowermodule}"
0372                         IMPORTED TRUE
0373                     )
0374                 endforeach()
0375             endif()
0376         endif()
0377 
0378         # prepare base dirs, working file names and other vars
0379         if (DEFINED ARGS_BASE_NAME)
0380             set(_basename ${ARGS_BASE_NAME})
0381         else()
0382             set(_basename ${ARGS_NAME})
0383         endif()
0384         set(_qch_file_basename "${_basename}.qch")
0385         set(_tags_file_basename "${_basename}.tags")
0386         set(_qch_buildpath "${CMAKE_CURRENT_BINARY_DIR}/${_qch_file_basename}")
0387         set(_tags_buildpath "${CMAKE_CURRENT_BINARY_DIR}/${_tags_file_basename}")
0388         set(_apidox_builddir "${CMAKE_CURRENT_BINARY_DIR}/${_basename}_ECMDoxygenQCH")
0389         if (DEFINED ARGS_NAMESPACE)
0390             set(_namespace "${ARGS_NAMESPACE}")
0391         else()
0392             set(_namespace "${ARGS_ORG_DOMAIN}.${ARGS_NAME}")
0393         endif()
0394         string(REPLACE "." "_" _dotLessVersion ${ARGS_VERSION})
0395         set(_versioned_namespace "${_namespace}.${_dotLessVersion}")
0396         set(_sources)
0397         set(_dep_tagfiles)
0398         set(_dep_qch_targets)
0399 
0400         ### Create doxygen config file
0401         set(_doxygenconfig_file "${CMAKE_CURRENT_BINARY_DIR}/${_basename}_ECMDoxygenQCH.config")
0402         if (DEFINED ARGS_CONFIG_TEMPLATE)
0403             set(_doxygenconfig_template_file "${ARGS_CONFIG_TEMPLATE}")
0404         else()
0405             set(_doxygenconfig_template_file "${_module_dir}/KDbDoxygenQCH.config.in")
0406         endif()
0407         # Setup variables used in config file template, ECM_DOXYGENQCH_*
0408         set(ECM_DOXYGENQCH_OUTPUTDIR "\"${_apidox_builddir}\"")
0409         set(ECM_DOXYGENQCH_TAGFILE "\"${_tags_buildpath}\"")
0410         set(ECM_DOXYGENQCH_LAYOUTFILE "\"${_module_dir}/KDbDoxygenQCHLayout.xml\"")
0411         set(ECM_DOXYGENQCH_IMAGEDIRS)
0412         foreach(_image_DIR IN LISTS ARGS_IMAGE_DIRS)
0413             if (NOT IS_ABSOLUTE ${_image_DIR})
0414                 set(_image_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${_image_DIR}")
0415             endif()
0416             # concat dirs separated by a break, it is no issue that first has also a leading break
0417             set(ECM_DOXYGENQCH_IMAGEDIRS "${ECM_DOXYGENQCH_IMAGEDIRS} \\\n\"${_image_DIR}\"")
0418         endforeach()
0419         set(ECM_DOXYGENQCH_EXAMPLEDIRS)
0420         foreach(_example_DIR IN LISTS ARGS_EXAMPLE_DIRS)
0421             if (NOT IS_ABSOLUTE ${_example_DIR})
0422                 set(_example_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${_example_DIR}")
0423             endif()
0424             # concat dirs separated by a break, it is no issue that first has also a leading break
0425             set(ECM_DOXYGENQCH_EXAMPLEDIRS "${ECM_DOXYGENQCH_EXAMPLEDIRS} \\\n\"${_example_DIR}\"")
0426         endforeach()
0427         if (ARGS_MD_MAINPAGE)
0428             if (NOT IS_ABSOLUTE ${ARGS_MD_MAINPAGE})
0429                 set(ARGS_MD_MAINPAGE "${CMAKE_CURRENT_SOURCE_DIR}/${ARGS_MD_MAINPAGE}")
0430             endif()
0431             set(ECM_DOXYGENQCH_MAINPAGE_MDFILE "\"${ARGS_MD_MAINPAGE}\"")
0432         else()
0433             set(ECM_DOXYGENQCH_MAINPAGE_MDFILE)
0434         endif()
0435         set(ECM_DOXYGENQCH_INPUT)
0436         if (ARGS_SOURCE_DIRS)
0437             foreach(_source_DIR IN LISTS ARGS_SOURCE_DIRS)
0438                 if (NOT IS_ABSOLUTE ${_source_DIR})
0439                     set(_source_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${_source_DIR}")
0440                 endif()
0441                 # concat dirs separated by a break, it is no issue that first has also a leading break
0442                 set(ECM_DOXYGENQCH_INPUT "${ECM_DOXYGENQCH_INPUT} \\\n\"${_source_DIR}\"")
0443             endforeach()
0444             if (ARGS_MD_MAINPAGE)
0445                 set(ECM_DOXYGENQCH_INPUT "${ECM_DOXYGENQCH_INPUT} \\\n\"${ARGS_MD_MAINPAGE}\"")
0446             endif()
0447             set(ECM_DOXYGENQCH_FILE_PATTERNS "*.h *.cpp *.hpp *.hh *.cc *.h++ *.c++ *.hxx *.cxx *.dox *.md")
0448         else()
0449             foreach(_source IN LISTS ARGS_SOURCES)
0450                 if (NOT IS_ABSOLUTE ${_source})
0451                     set(_source "${CMAKE_CURRENT_SOURCE_DIR}/${_source}")
0452                 endif()
0453                 list(APPEND _sources "${_source}")
0454             endforeach()
0455             if (ARGS_MD_MAINPAGE)
0456                 list(FIND _sources ${ARGS_MD_MAINPAGE} _mainpage_index)
0457                 if (_mainpage_index STREQUAL -1)
0458                     list(APPEND _sources "${ARGS_MD_MAINPAGE}")
0459                 endif()
0460             endif()
0461             foreach(_source IN LISTS _sources)
0462                 # concat sources separated by a break, it is no issue that first has also a leading break
0463                 set(ECM_DOXYGENQCH_INPUT "${ECM_DOXYGENQCH_INPUT} \\\n\"${_source}\"")
0464             endforeach()
0465             set(ECM_DOXYGENQCH_FILE_PATTERNS "")
0466         endif()
0467 
0468         set(ECM_DOXYGENQCH_PROJECTNAME ${ARGS_NAME})
0469         file(RELATIVE_PATH _builddirrelative_filepath "${_apidox_builddir}/html"  ${_qch_buildpath})
0470         set(ECM_DOXYGENQCH_FILEPATH "\"${_builddirrelative_filepath}\"")
0471         set(ECM_DOXYGENQCH_PROJECTVERSION ${ARGS_VERSION})
0472         set(ECM_DOXYGENQCH_VIRTUALFOLDER "${ARGS_NAME}")
0473         set(ECM_DOXYGENQCH_FULLNAMESPACE ${_versioned_namespace})
0474         set(ECM_DOXYGENQCH_BLANK_MACROS)
0475         foreach(_macro IN LISTS ARGS_BLANK_MACROS)
0476             # concat dirs separated by a break, it is no issue that first has also a leading break
0477             set(ECM_DOXYGENQCH_BLANK_MACROS "${ECM_DOXYGENQCH_BLANK_MACROS} \\\n${_macro}=\"\"")
0478         endforeach()
0479         set(ECM_DOXYGENQCH_TAGFILES)
0480         foreach(_versioned_postfix "" "_VERSIONED")
0481             foreach(_link_qch IN LISTS ARGS_LINK_QCHS${_versioned_postfix})
0482                 set(_target_usable TRUE)
0483                 if (NOT TARGET ${_link_qch})
0484                     message(STATUS "No such target ${_link_qch} defined when calling kdb_add_qch().")
0485                     set(_target_usable FALSE)
0486                 elseif()
0487                     foreach(_propertyname
0488                         DOXYGEN_TAGFILE
0489                         QHP_NAMESPACE${_versioned_postfix}
0490                         QHP_VIRTUALFOLDER
0491                     )
0492                         get_target_property(_property ${_target} ${_propertyname})
0493                         if(NOT "${_property}")
0494                             message(STATUS "No property ${_propertyname} set on ${_link_qch} when calling kdb_add_qch().")
0495                             set(_target_usable FALSE)
0496                         endif()
0497                     endforeach()
0498                 endif()
0499                 if(_target_usable)
0500                     list(APPEND _dep_qch_targets ${_link_qch})
0501                     get_target_property(_link_qch_tagfile ${_link_qch} DOXYGEN_TAGFILE)
0502                     get_target_property(_link_qch_tagfile_build ${_link_qch} DOXYGEN_TAGFILE_BUILD)
0503                     get_target_property(_link_qch_namespace ${_link_qch} QHP_NAMESPACE${_versioned_postfix})
0504                     get_target_property(_link_qch_virtualfolder ${_link_qch} QHP_VIRTUALFOLDER)
0505                     # if same build, then prefer build version over any installed one
0506                     if (_link_qch_tagfile_build)
0507                         set(_link_qch_tagfile ${_link_qch_tagfile_build})
0508                         list(APPEND _dep_tagfiles "${_link_qch_tagfile}")
0509                     endif()
0510                     set(_tagfile_entry "\"${_link_qch_tagfile}=qthelp://${_link_qch_namespace}/${_link_qch_virtualfolder}/\"")
0511                     # concat dirs separated by a break, it is no issue that first has also a leading break
0512                     set(ECM_DOXYGENQCH_TAGFILES "${ECM_DOXYGENQCH_TAGFILES} \\\n${_tagfile_entry}")
0513                 else()
0514                     message(WARNING "No linking to API dox of ${_link_qch}.")
0515                 endif()
0516             endforeach()
0517         endforeach()
0518 
0519         set(ECM_DOXYGENQCH_WARN_LOGFILE "\"${_doxygenconfig_file}.log\"")
0520         if(ARGS_VERBOSE)
0521             set(ECM_DOXYGENQCH_QUIET "NO")
0522         else()
0523             set(ECM_DOXYGENQCH_QUIET "YES")
0524         endif()
0525         set(ECM_DOXYGENQCH_PERL_EXECUTABLE "${PERL_EXECUTABLE}")
0526 
0527         configure_file(
0528             "${_doxygenconfig_template_file}"
0529             "${_doxygenconfig_file}"
0530             @ONLY
0531         )
0532 
0533         set(_qch_INSTALLPATH ${ARGS_QCH_INSTALL_DESTINATION})
0534         set(_tags_INSTALLPATH ${ARGS_TAGFILE_INSTALL_DESTINATION})
0535         file(RELATIVE_PATH _relative_qch_file ${CMAKE_BINARY_DIR}  ${_qch_buildpath})
0536         file(RELATIVE_PATH _relative_tags_file ${CMAKE_BINARY_DIR}  ${_tags_buildpath})
0537         add_custom_command(
0538             OUTPUT ${_qch_buildpath} ${_tags_buildpath}
0539             COMMENT "Generating ${_relative_qch_file}, ${_relative_tags_file}"
0540             COMMAND cmake -E remove_directory "${ECM_DOXYGENQCH_OUTPUTDIR}"
0541             COMMAND cmake -E make_directory "${ECM_DOXYGENQCH_OUTPUTDIR}"
0542             COMMAND ${DOXYGEN_EXECUTABLE} "${_doxygenconfig_file}"
0543             DEPENDS ${_doxygenconfig_file} ${_sources} ${_dep_tagfiles} ${_dep_qch_targets}
0544         )
0545         add_custom_target(${target_name} ALL DEPENDS ${_qch_buildpath} ${_tags_buildpath})
0546         set_target_properties(${target_name} PROPERTIES
0547             DOXYGEN_TAGFILE "${_qch_INSTALLPATH}/${_tags_file_basename}"
0548             DOXYGEN_TAGFILE_BUILD "${_tags_buildpath}"
0549             QHP_NAMESPACE "${_namespace}"
0550             QHP_NAMESPACE_VERSIONED  "${_versioned_namespace}"
0551             QHP_VIRTUALFOLDER "${ECM_DOXYGENQCH_VIRTUALFOLDER}"
0552         )
0553 
0554         install(FILES
0555             ${_qch_buildpath}
0556             DESTINATION ${_qch_INSTALLPATH}
0557             COMPONENT Devel
0558         )
0559 
0560         install(FILES
0561             ${_tags_buildpath}
0562             DESTINATION ${_tags_INSTALLPATH}
0563             COMPONENT Devel
0564         )
0565     endif()
0566 
0567 endfunction()
0568 
0569 
0570 function(kdb_install_qch_export)
0571     set(options )
0572     set(oneValueArgs FILE DESTINATION COMPONENT)
0573     set(multiValueArgs TARGETS)
0574 
0575     cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
0576 
0577     if(NOT DEFINED ARGS_FILE)
0578         message(FATAL_ERROR "FILE needs to be defined when calling kdb_install_qch_export().")
0579     endif()
0580 
0581     if(NOT DEFINED ARGS_DESTINATION)
0582         message(FATAL_ERROR "DESTINATION needs to be defined when calling kdb_install_qch_export().")
0583     endif()
0584 
0585     # TARGETS may be empty (and ARGS_TARGETS will not be defined then by cmake_parse_arguments)
0586 
0587     set(_content
0588 "# Generated by kdb_install_qch_export()
0589 # Any changes to this file will be overwritten by the next CMake run.
0590 "
0591     )
0592 
0593     foreach(_target IN LISTS ARGS_TARGETS)
0594         set(_target_usable TRUE)
0595 
0596         if (NOT TARGET ${_target})
0597             message(STATUS "No such target ${_target} when calling kdb_install_qch_export().")
0598             set(_target_usable FALSE)
0599         else()
0600             foreach(_propertyname
0601                 DOXYGEN_TAGFILE
0602                 QHP_NAMESPACE
0603                 QHP_NAMESPACE_VERSIONED
0604                 QHP_VIRTUALFOLDER
0605             )
0606                 get_target_property(_property ${_target} ${_propertyname})
0607                 if(NOT _property)
0608                     message(STATUS "No property ${_propertyname} set on ${_target} when calling kdb_install_qch_export(). <${_property}>")
0609                     set(_target_usable FALSE)
0610                 endif()
0611             endforeach()
0612         endif()
0613         if(_target_usable)
0614             get_target_property(_tagfile ${_target} DOXYGEN_TAGFILE)
0615             get_target_property(_namespace ${_target} QHP_NAMESPACE)
0616             get_target_property(_namespace_versioned ${_target} QHP_NAMESPACE_VERSIONED)
0617             get_target_property(_virtualfolder ${_target} QHP_VIRTUALFOLDER)
0618             set(_content "${_content}
0619 if (NOT TARGET ${_target})
0620 
0621 add_custom_target(${_target})
0622 set_target_properties(${_target} PROPERTIES
0623     DOXYGEN_TAGFILE \"${_tagfile}\"
0624     QHP_NAMESPACE \"${_namespace}\"
0625     QHP_NAMESPACE_VERSIONED \"${_namespace_versioned}\"
0626     QHP_VIRTUALFOLDER \"${_virtualfolder}\"
0627     IMPORTED TRUE
0628 )
0629 
0630 endif()
0631 "
0632             )
0633         else()
0634             message(STATUS "No target exported for ${_target}.")
0635         endif()
0636     endforeach()
0637 
0638     if (NOT IS_ABSOLUTE ${ARGS_FILE})
0639         set(ARGS_FILE "${CMAKE_CURRENT_BINARY_DIR}/${ARGS_FILE}")
0640     endif()
0641 
0642     file(GENERATE
0643         OUTPUT "${ARGS_FILE}"
0644         CONTENT "${_content}"
0645     )
0646 
0647     if (DEFINED ARGS_COMPONENT)
0648         set(_component COMPONENT ${ARGS_COMPONENT})
0649     endif()
0650     install(
0651         FILES "${ARGS_FILE}"
0652         DESTINATION "${ARGS_DESTINATION}"
0653         ${_component}
0654     )
0655 
0656 endfunction()