Changeset View
Changeset View
Standalone View
Standalone View
cmake/modules/KReportAddQCH.cmake
- This file was added.
1 | #.rst: | ||||
---|---|---|---|---|---|
2 | # KReportAddQCH | ||||
3 | # ------------------ | ||||
4 | # | ||||
5 | # This module provides the ``kreport_add_qch`` function for generating API | ||||
6 | # documentation files in the QCH format, and the ``kreport_install_qch_export`` | ||||
7 | # function for generating and installing exported CMake targets for such | ||||
8 | # generated QCH files to enable builds of other software with generation of | ||||
9 | # QCH files to create links into the given QCH files. | ||||
10 | # | ||||
11 | # :: | ||||
12 | # | ||||
13 | # kreport_add_qch(<name> | ||||
14 | # OUTPUT_BASENAME <basename> | ||||
15 | # VERSION <version> | ||||
16 | # QCH_INSTALL_DESTINATION <qchfile_install_path> | ||||
17 | # TAGFILE_INSTALL_DESTINATION <tagsfile_install_path> | ||||
18 | # [SOURCE_DIRS <dir> [<dir2> [...]]] | ||||
19 | # [SOURCES <file> [<file2> [...]]] | ||||
20 | # |MD_MAINPAGE <md_file>] | ||||
21 | # [IMAGE_DIRS <idir> [<idir2> [...]]] | ||||
22 | # [EXAMPLE_DIRS <edir> [<edir2> [...]]] | ||||
23 | # [ORG_DOMAIN <domain>] | ||||
24 | # [NAMESPACE <namespace>] | ||||
25 | # [LINK_QCHS <qch> [<qch2> [...]]] | ||||
26 | # [LINK_QCHS_VERSIONED <qchv> [<qchv2> [...]]] | ||||
27 | # [BLANK_MACROS <macro> [<macro2> [...]]] | ||||
28 | # [CONFIG_TEMPLATE <configtemplate_file>] | ||||
29 | # [VERBOSE] | ||||
30 | # ) | ||||
31 | # | ||||
32 | # This macro adds a target called <name> for the creation of an API | ||||
33 | # documentation manual named ``<basename>.qch``in the QCH format from the | ||||
34 | # given sources. | ||||
35 | # It currently uses doxygen, future versions might optionally also allow other | ||||
36 | # tools. | ||||
37 | # Next to the QCH file the target will generate a corresponding doxygen tag | ||||
38 | # file name ``<basename>.tags``, which enables creating links from other | ||||
39 | # documentation into the generated QCH file. | ||||
40 | # | ||||
41 | # If the required tools are not found, the macro will skip creation of the | ||||
42 | # target and only emit a warning, so the use of the macro can be introduced | ||||
43 | # without requiring anyone to also have the needed tools present at that time. | ||||
44 | # This behaviour might change in future versions to result in a fail instead. | ||||
45 | # It is recommended to make the use of this macro optional, by depending | ||||
46 | # the call to ``kreport_add_qch()`` on a CMake option being set, with a name like | ||||
47 | # ``BUILD_QCH`` and being TRUE by default. This will allow the developers to | ||||
48 | # saves resources on normal source development build cycles by setting this | ||||
49 | # option to FALSE. | ||||
50 | # | ||||
51 | # The macro will set the target properties DOXYGEN_TAGFILE, QHP_NAMESPACE, | ||||
52 | # QHP_NAMESPACE_VERSIONED and QHP_VIRTUALFOLDER to the respective values, to | ||||
53 | # allow other code access to them, e.g. the macro kreport_install_qch_export(). | ||||
54 | # To enable the use of the target <name> as item for LINK_QCHS or | ||||
55 | # LINK_QCHS_VERSIONED in further ``kreport_add_qch()`` calls in the current build, | ||||
56 | # additionally a target property DOXYGEN_TAGFILE_BUILD is set, with the path | ||||
57 | # of the created doxygen tag file in the build dir. | ||||
58 | # If existing, ``kreport_add_qch()`` will use this property instead of | ||||
59 | # DOXYGEN_TAGFILE for access to the tags file. | ||||
60 | # | ||||
61 | # OUTPUT_BASENAME specifies the base name for the generated documentation and | ||||
62 | # the files. | ||||
63 | # | ||||
64 | # VERSION specifies the version of the library for which the documentation is | ||||
65 | # created. | ||||
66 | # | ||||
67 | # SOURCE_DIRS specifies the dirs (incl. subdirs) with the source files for | ||||
68 | # which the API documentation should be generated. Dirs can be relative to | ||||
69 | # the current source dir. Dependencies to the files in the dirs are not | ||||
70 | # tracked currently, other than with the SOURCES argument. So do not use for | ||||
71 | # sources generated during the build. | ||||
72 | # Needs to be used when SOURCES or CONFIG_TEMPLATE are not used. | ||||
73 | # | ||||
74 | # SOURCES specifies the source files for which the API documentation should be | ||||
75 | # generated. | ||||
76 | # Needs to be used when SOURCE_DIRS or CONFIG_TEMPLATE are not used. | ||||
77 | # | ||||
78 | # MD_MAINPAGE specifies a file in Markdown format that should be used as main | ||||
79 | # page. This page will overrule any ``\mainpage`` command in the included | ||||
80 | # sources. | ||||
81 | # | ||||
82 | # IMAGE_DIRS specifies the dirs which contain images that are included in the | ||||
83 | # documentation. Dirs can be relative to the current source dir. | ||||
84 | # | ||||
85 | # EXAMPLE_DIRS specifies the dirs which contain examples that are included in | ||||
86 | # the documentation. Dirs can be relative to the current source dir. | ||||
87 | # | ||||
88 | # QCH_INSTALL_DESTINATION specifies where the generated QCH file will be | ||||
89 | # installed. | ||||
90 | # | ||||
91 | # TAGFILE_INSTALL_DESTINATION specifies where the generated tag file will be | ||||
92 | # installed. | ||||
93 | # | ||||
94 | # NAMESPACE can be used to set a custom namespace <namespace> of the generated | ||||
95 | # QCH file. The namepspace is used as the unique id by QHelpEngine (cmp. | ||||
96 | # http://doc.qt.io/qt-5/qthelpproject.html#namespace). | ||||
97 | # The default namespace is ``<domain>.<basename>``. | ||||
98 | # Needs to be used when ORG_DOMAIN is not used. | ||||
99 | # | ||||
100 | # ORG_DOMAIN can be used to define the organization domain prefix for the | ||||
101 | # default namespace of the generated QCH file. | ||||
102 | # Needs to be used when NAMESPACE is not used. | ||||
103 | # | ||||
104 | # LINK_QCHS specifies a list of other QCH targets which should be used for | ||||
105 | # creating references to API documenation of code in external libraries. | ||||
106 | # For each target <qch> in the list these target properties are expected to be | ||||
107 | # defined: DOXYGEN_TAGFILE, QHP_NAMESPACE and QHP_VIRTUALFOLDER. | ||||
108 | # If any of these is not existing, <qch> will be ignored. | ||||
109 | # Use the macro kreport_install_qch_export for exporting a target with these | ||||
110 | # properties with the CMake config of a library. | ||||
111 | # Any target <qch> can also be one created before in the same buildsystem by | ||||
112 | # another call of ``kreport_add_qch()``. | ||||
113 | # | ||||
114 | # LINK_QCHS_VERSIONED does basically the same as LINK_QCHS, but binds the links | ||||
115 | # to a certain version. | ||||
116 | # For each <qchv> in the list these target properties are expected to be | ||||
117 | # defined: DOXYGEN_TAGFILE, QHP_NAMESPACE_VERSIONED and QHP_VIRTUALFOLDER. | ||||
118 | # If any of these is not existing, <qchv> will be ignored. | ||||
119 | # Use the macro kreport_install_qch_export for exporting a target with these | ||||
120 | # properties with the CMake config of a library. | ||||
121 | # Any <qchv> can also be one created before in the same buildsystem by another | ||||
122 | # call of ``kreport_add_qch()``. | ||||
123 | # | ||||
124 | # BLANK_MACROS specifies a list of C/C++ macro names which should be ignored by | ||||
125 | # the API dox generation tool and handled as if they resolve to empty strings. | ||||
126 | # Examples are export macros only defined in generated files, so whose | ||||
127 | # definition might be not available to the tool. | ||||
128 | # | ||||
129 | # CONFIG_TEMPLATE specifies a custom cmake template file for the config file | ||||
130 | # that is created to control the execution of the API dox generation tool. | ||||
131 | # The following CMake variables need to be used: | ||||
132 | # ECM_DOXYGENQCH_PERL_EXECUTABLE, ECM_DOXYGENQCH_QHELPGENERATOR_EXECUTABLE, | ||||
133 | # ECM_DOXYGENQCH_FILEPATH, ECM_DOXYGENQCH_TAGFILE. | ||||
134 | # The following CMake variables can be used: | ||||
135 | # ECM_DOXYGENQCH_PROJECTNAME, ECM_DOXYGENQCH_PROJECTVERSION, | ||||
136 | # ECM_DOXYGENQCH_VIRTUALFOLDER, ECM_DOXYGENQCH_FULLNAMESPACE, | ||||
137 | # ECM_DOXYGENQCH_TAGFILES, | ||||
138 | # ECM_DOXYGENQCH_WARN_LOGFILE, ECM_DOXYGENQCH_QUIET. | ||||
139 | # There is no guarantue that the other CMake variables currently used in the | ||||
140 | # default config file template will also be present with the same semantics | ||||
141 | # in future versions of this macro. | ||||
142 | # | ||||
143 | # VERBOSE tells the API dox generation tool to be more verbose about its | ||||
144 | # activity. | ||||
145 | # | ||||
146 | # Example usage: | ||||
147 | # | ||||
148 | # .. code-block:: cmake | ||||
149 | # | ||||
150 | # kreport_add_qch( | ||||
151 | # MyLib_QCH | ||||
152 | # OUTPUT_BASENAME MyLib | ||||
153 | # VERSION "0.42.0" | ||||
154 | # ORG_DOMAIN org.myorg | ||||
155 | # SOURCE_DIRS | ||||
156 | # src | ||||
157 | # LINK_QCHS | ||||
158 | # Qt5Core_QCH | ||||
159 | # Qt5Xml_QCH | ||||
160 | # Qt5Gui_QCH | ||||
161 | # Qt5Widgets_QCH | ||||
162 | # BLANK_MACROS | ||||
163 | # MyLib_EXPORT | ||||
164 | # MyLib_DEPRECATED | ||||
165 | # TAGFILE_INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/share/docs/tags | ||||
166 | # QCH_INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/share/docs/qch | ||||
167 | # ) | ||||
168 | # | ||||
169 | # Example usage (with two QCH files, second linking first): | ||||
170 | # | ||||
171 | # .. code-block:: cmake | ||||
172 | # | ||||
173 | # kreport_add_qch( | ||||
174 | # MyLib_QCH | ||||
175 | # OUTPUT_BASENAME MyLib | ||||
176 | # VERSION ${MyLib_VERSION} | ||||
177 | # ORG_DOMAIN org.myorg | ||||
178 | # SOURCES ${MyLib_PUBLIC_HEADERS} | ||||
179 | # MD_MAINPAGE src/mylib/README.md | ||||
180 | # LINK_QCHS Qt5Core_QCH | ||||
181 | # TAGFILE_INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/share/docs/tags | ||||
182 | # QCH_INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/share/docs/qch | ||||
183 | # ) | ||||
184 | # kreport_add_qch( | ||||
185 | # MyOtherLib_QCH | ||||
186 | # OUTPUT_BASENAME MyOtherLib | ||||
187 | # VERSION ${MyOtherLib_VERSION} | ||||
188 | # ORG_DOMAIN org.myorg | ||||
189 | # SOURCES ${MyOtherLib_PUBLIC_HEADERS} | ||||
190 | # MD_MAINPAGE src/myotherlib/README.md | ||||
191 | # LINK_QCHS Qt5Core_QCH MyLib_QCH | ||||
192 | # TAGFILE_INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/share/docs/tags | ||||
193 | # QCH_INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/share/docs/qch | ||||
194 | # ) | ||||
195 | # | ||||
196 | # :: | ||||
197 | # | ||||
198 | # kreport_install_qch_export( | ||||
199 | # TARGETS [<name> [<name2> [...]]] | ||||
200 | # FILE <file> | ||||
201 | # DESTINATION <dest> | ||||
202 | # [COMPONENT <component>}] | ||||
203 | # ) | ||||
204 | # | ||||
205 | # This macro creates and installs a CMake file <file> which exports the given | ||||
206 | # QCH targets <name> etc., so they can be picked up by CMake-based builds of | ||||
207 | # other software that also generate QCH files (using ``kreport_add_qch()``) and | ||||
208 | # which should include links to the QCH files created by the given targets. | ||||
209 | # The installed CMake file <file> is expected to be included by the CMake | ||||
210 | # config file created for the software the related QCH files are documenting. | ||||
211 | # | ||||
212 | # TARGETS specifies the QCH targets which should be exported. If a target does | ||||
213 | # not exist or does not have all needed properties, a warning will be | ||||
214 | # generated and the target skipped. | ||||
215 | # This behaviour might change in future versions to result in a fail instead. | ||||
216 | # | ||||
217 | # FILE specifies the name of the created CMake file, typically with a .cmake | ||||
218 | # extension. | ||||
219 | # | ||||
220 | # DESTINATION specifies the directory on disk to which the file will be | ||||
221 | # installed. It usually is the same as the one where the CMake config files | ||||
222 | # for this software are installed. | ||||
223 | # | ||||
224 | # COMPONENT specifies the the installation component name with which the | ||||
225 | # install rule is associated. | ||||
226 | # | ||||
227 | # Example usage: | ||||
228 | # | ||||
229 | # .. code-block:: cmake | ||||
230 | # | ||||
231 | # kreport_install_qch_export( | ||||
232 | # TARGETS MyLib_QCH | ||||
233 | # FILE MyLibQCHTargets.cmake | ||||
234 | # DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/cmake/MyLib" | ||||
235 | # COMPONENT Devel | ||||
236 | # ) | ||||
237 | # | ||||
238 | # Since 5.29.0. | ||||
239 | | ||||
240 | #============================================================================= | ||||
241 | # Copyright 2016 Friedrich W. H. Kossebau <kossebau@kde.org> | ||||
242 | # | ||||
243 | # Redistribution and use in source and binary forms, with or without | ||||
244 | # modification, are permitted provided that the following conditions | ||||
245 | # are met: | ||||
246 | # | ||||
247 | # 1. Redistributions of source code must retain the copyright | ||||
248 | # notice, this list of conditions and the following disclaimer. | ||||
249 | # 2. Redistributions in binary form must reproduce the copyright | ||||
250 | # notice, this list of conditions and the following disclaimer in the | ||||
251 | # documentation and/or other materials provided with the distribution. | ||||
252 | # 3. The name of the author may not be used to endorse or promote products | ||||
253 | # derived from this software without specific prior written permission. | ||||
254 | # | ||||
255 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||||
256 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||||
257 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||||
258 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||||
259 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||||
260 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||
261 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||||
262 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||
263 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||||
264 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
265 | | ||||
266 | # needed to find helper files | ||||
267 | get_filename_component(_module_dir ${CMAKE_CURRENT_LIST_FILE} PATH) | ||||
268 | | ||||
269 | # Estimate KREPORT_QTQCH_FULL_INSTALL_DIR | ||||
270 | include(KDEInstallDirs) # for KDE_INSTALL_USE_QT_SYS_PATHS & KDE_INSTALL_FULL_DATAROOTDIR | ||||
271 | include("${_module_dir}/KReportQueryQmake.cmake") | ||||
272 | if(KDE_INSTALL_USE_QT_SYS_PATHS) | ||||
273 | query_qmake(qt_docs_dir QT_INSTALL_DOCS) | ||||
274 | set(KREPORT_QTQCH_FULL_INSTALL_DIR "${qt_docs_dir}") | ||||
275 | else() | ||||
276 | set(KREPORT_QTQCH_FULL_INSTALL_DIR "${KDE_INSTALL_FULL_DATAROOTDIR}/doc") | ||||
277 | endif() | ||||
278 | | ||||
279 | include(CMakeParseArguments) | ||||
280 | | ||||
281 | function(kreport_add_qch target_name) | ||||
282 | # Parse arguments | ||||
283 | set(options VERBOSE) | ||||
284 | set(oneValueArgs OUTPUT_BASENAME QCH_INSTALL_DESTINATION TAGFILE_INSTALL_DESTINATION VERSION NAMESPACE MD_MAINPAGE ORG_DOMAIN CONFIG_TEMPLATE) | ||||
285 | set(multiValueArgs SOURCE_DIRS SOURCES IMAGE_DIRS EXAMPLE_DIRS BLANK_MACROS LINK_QCHS LINK_QCHS_VERSIONED) | ||||
286 | cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) | ||||
287 | | ||||
288 | # check required args | ||||
289 | foreach(_arg_name OUTPUT_BASENAME QCH_INSTALL_DESTINATION TAGFILE_INSTALL_DESTINATION VERSION) | ||||
290 | if(NOT DEFINED ARGS_${_arg_name}) | ||||
291 | message(FATAL_ERROR "${_arg_name} needs to be defined when calling kreport_add_qch") | ||||
292 | endif() | ||||
293 | endforeach() | ||||
294 | if(NOT DEFINED ARGS_SOURCE_DIRS AND NOT DEFINED ARGS_SOURCES AND NOT DEFINED ARGS_CONFIG_TEMPLATE) | ||||
295 | message(FATAL_ERROR "SOURCE_DIRS or SOURCES needs to be defined when calling kreport_add_qch") | ||||
296 | endif() | ||||
297 | if(DEFINED ARGS_SOURCE_DIRS AND DEFINED ARGS_SOURCES) | ||||
298 | message(FATAL_ERROR "Either SOURCE_DIRS or SOURCES, not both, needs to be defined when calling kreport_add_qch") | ||||
299 | endif() | ||||
300 | if(NOT DEFINED ARGS_ORG_DOMAIN AND NOT DEFINED ARGS_NAMESPACE) | ||||
301 | message(FATAL_ERROR "ORG_DOMAIN or NAMESPACE needs to be defined when calling kreport_add_qch") | ||||
302 | endif() | ||||
303 | | ||||
304 | # create QCH targets for Qt | ||||
305 | # Ideally one day Qt CMake Config files provide these | ||||
306 | if(NOT TARGET Qt5Core_QCH) | ||||
307 | # get Qt version, if any | ||||
308 | find_package(Qt5Core CONFIG QUIET) | ||||
309 | # lookup tag files | ||||
310 | query_qmake(qt_docs_dir QT_INSTALL_DOCS) | ||||
311 | find_path(_qtcoreTagsPath qtcore/qtcore.tags | ||||
312 | PATHS | ||||
313 | ${qt_docs_dir} | ||||
314 | ) | ||||
315 | | ||||
316 | # TODO: if not found, try qmake -query QT_INSTALL_DOCS. or perhaps try that first | ||||
317 | if(Qt5Core_FOUND AND _qtcoreTagsPath) | ||||
318 | string(REPLACE "." "" _version ${Qt5Core_VERSION}) | ||||
319 | # TODO: properly find each tag file | ||||
320 | # TODO: complete list of Qt modules | ||||
321 | foreach(_module | ||||
322 | Bluetooth Concurrent Core DBus Gui Location Multimedia MultimediaWidgets | ||||
323 | Network Positioning PrintSupport Qml Quick Sensors SerialPort Sql Svg | ||||
324 | WebEngine WebView Widgets Xml XmlPatterns | ||||
325 | ) | ||||
326 | string(TOLOWER ${_module} _lowermodule) | ||||
327 | | ||||
328 | add_custom_target(Qt5${_module}_QCH) | ||||
329 | set_target_properties(Qt5${_module}_QCH PROPERTIES | ||||
330 | DOXYGEN_TAGFILE "${_qtcoreTagsPath}/qt${_lowermodule}/qt${_lowermodule}.tags" | ||||
331 | QHP_NAMESPACE "org.qt-project.qt${_lowermodule}" | ||||
332 | QHP_NAMESPACE_VERSIONED "org.qt-project.qt${_lowermodule}.${_version}" | ||||
333 | QHP_VIRTUALFOLDER "qt${_lowermodule}" | ||||
334 | IMPORTED TRUE | ||||
335 | ) | ||||
336 | endforeach() | ||||
337 | endif() | ||||
338 | endif() | ||||
339 | | ||||
340 | # find required tools | ||||
341 | find_package(Perl) | ||||
342 | set_package_properties(Perl PROPERTIES | ||||
343 | TYPE OPTIONAL | ||||
344 | ) | ||||
345 | find_package(Doxygen) | ||||
346 | set_package_properties(Doxygen PROPERTIES | ||||
347 | TYPE OPTIONAL | ||||
348 | DESCRIPTION "Tool for API Documentation generation" | ||||
349 | URL "http://www.doxygen.org/" | ||||
350 | ) | ||||
351 | if (DOXYGEN_FOUND AND DOXYGEN_VERSION VERSION_LESS 1.8.13 AND NOT DOXYGEN_PATCHED_JSFILESADDED) | ||||
352 | message(WARNING "Make sure Doxygen is patched with https://github.com/doxygen/doxygen/commit/bf9415698e53d79b, then pass -DDOXYGEN_PATCHED_JSFILESADDED=ON to cmake") | ||||
353 | set(DOXYGEN_FOUND FALSE) | ||||
354 | endif() | ||||
355 | # TODO: use Qt5::qhelpgenerator for Qt >= 5.7.1 | ||||
356 | find_program(ECM_DOXYGENQCH_QHELPGENERATOR_EXECUTABLE NAMES qhelpgenerator-qt5 qhelpgenerator) | ||||
357 | | ||||
358 | # prepare base dirs, working file names and other vars | ||||
359 | set(_qch_file_basename "${ARGS_OUTPUT_BASENAME}.qch") | ||||
360 | set(_tags_file_basename "${ARGS_OUTPUT_BASENAME}.tags") | ||||
361 | set(_qch_buildpath "${CMAKE_CURRENT_BINARY_DIR}/${_qch_file_basename}") | ||||
362 | set(_tags_buildpath "${CMAKE_CURRENT_BINARY_DIR}/${_tags_file_basename}") | ||||
363 | set(_apidox_builddir "${CMAKE_CURRENT_BINARY_DIR}/${ARGS_OUTPUT_BASENAME}_ECMDoxygenQCH") | ||||
364 | if (DEFINED ARGS_NAMESPACE) | ||||
365 | set(_namespace "${ARGS_NAMESPACE}") | ||||
366 | else() | ||||
367 | set(_namespace "${ARGS_ORG_DOMAIN}.${ARGS_OUTPUT_BASENAME}") | ||||
368 | endif() | ||||
369 | string(REPLACE "." "_" _dotLessVersion ${ARGS_VERSION}) | ||||
370 | set(_versioned_namespace "${_namespace}.${_dotLessVersion}") | ||||
371 | set(_sources) | ||||
372 | set(_dep_tagfiles) | ||||
373 | set(_dep_qch_targets) | ||||
374 | | ||||
375 | ### Create doxygen config file | ||||
376 | set(_doxygenconfig_file "${CMAKE_CURRENT_BINARY_DIR}/${ARGS_OUTPUT_BASENAME}_ECMDoxygenQCH.config") | ||||
377 | if (DEFINED ARGS_CONFIG_TEMPLATE) | ||||
378 | set(_doxygenconfig_template_file "${ARGS_CONFIG_TEMPLATE}") | ||||
379 | else() | ||||
380 | set(_doxygenconfig_template_file "${_module_dir}/KReportDoxygenQCH.config.in") | ||||
381 | endif() | ||||
382 | # Setup variables used in config file template, ECM_DOXYGENQCH_* | ||||
383 | set(ECM_DOXYGENQCH_OUTPUTDIR "\"${_apidox_builddir}\"") | ||||
384 | set(ECM_DOXYGENQCH_TAGFILE "\"${_tags_buildpath}\"") | ||||
385 | set(ECM_DOXYGENQCH_LAYOUTFILE "\"${_module_dir}/KReportDoxygenQCHLayout.xml\"") | ||||
386 | set(ECM_DOXYGENQCH_IMAGEDIRS) | ||||
387 | foreach(_image_DIR IN LISTS ARGS_IMAGE_DIRS) | ||||
388 | if (NOT IS_ABSOLUTE ${_image_DIR}) | ||||
389 | set(_image_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${_image_DIR}") | ||||
390 | endif() | ||||
391 | # concat dirs separated by a break, it is no issue that first has also a leading break | ||||
392 | set(ECM_DOXYGENQCH_IMAGEDIRS "${ECM_DOXYGENQCH_IMAGEDIRS} \\\n\"${_image_DIR}\"") | ||||
393 | endforeach() | ||||
394 | set(ECM_DOXYGENQCH_EXAMPLEDIRS) | ||||
395 | foreach(_example_DIR IN LISTS ARGS_EXAMPLE_DIRS) | ||||
396 | if (NOT IS_ABSOLUTE ${_example_DIR}) | ||||
397 | set(_example_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${_example_DIR}") | ||||
398 | endif() | ||||
399 | # concat dirs separated by a break, it is no issue that first has also a leading break | ||||
400 | set(ECM_DOXYGENQCH_EXAMPLEDIRS "${ECM_DOXYGENQCH_EXAMPLEDIRS} \\\n\"${_example_DIR}\"") | ||||
401 | endforeach() | ||||
402 | if (ARGS_MD_MAINPAGE) | ||||
403 | if (NOT IS_ABSOLUTE ${ARGS_MD_MAINPAGE}) | ||||
404 | set(ARGS_MD_MAINPAGE "${CMAKE_CURRENT_SOURCE_DIR}/${ARGS_MD_MAINPAGE}") | ||||
405 | endif() | ||||
406 | set(ECM_DOXYGENQCH_MAINPAGE_MDFILE "\"${ARGS_MD_MAINPAGE}\"") | ||||
407 | else() | ||||
408 | set(ECM_DOXYGENQCH_MAINPAGE_MDFILE) | ||||
409 | endif() | ||||
410 | set(ECM_DOXYGENQCH_INPUT) | ||||
411 | if (ARGS_SOURCE_DIRS) | ||||
412 | foreach(_source_DIR IN LISTS ARGS_SOURCE_DIRS) | ||||
413 | if (NOT IS_ABSOLUTE ${_source_DIR}) | ||||
414 | set(_source_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${_source_DIR}") | ||||
415 | endif() | ||||
416 | # concat dirs separated by a break, it is no issue that first has also a leading break | ||||
417 | set(ECM_DOXYGENQCH_INPUT "${ECM_DOXYGENQCH_INPUT} \\\n\"${_source_DIR}\"") | ||||
418 | endforeach() | ||||
419 | if (ARGS_MD_MAINPAGE) | ||||
420 | set(ECM_DOXYGENQCH_INPUT "${ECM_DOXYGENQCH_INPUT} \\\n\"${ARGS_MD_MAINPAGE}\"") | ||||
421 | endif() | ||||
422 | set(ECM_DOXYGENQCH_FILE_PATTERNS "*.h *.cpp *.hpp *.hh *.cc *.h++ *.c++ *.hxx *.cxx *.dox *.md") | ||||
423 | else() | ||||
424 | foreach(_source IN LISTS ARGS_SOURCES) | ||||
425 | if (NOT IS_ABSOLUTE ${_source}) | ||||
426 | set(_source "${CMAKE_CURRENT_SOURCE_DIR}/${_source}") | ||||
427 | endif() | ||||
428 | list(APPEND _sources "${_source}") | ||||
429 | endforeach() | ||||
430 | if (ARGS_MD_MAINPAGE) | ||||
431 | list(FIND _sources ${ARGS_MD_MAINPAGE} _mainpage_index) | ||||
432 | if (_mainpage_index STREQUAL -1) | ||||
433 | list(APPEND _sources "${ARGS_MD_MAINPAGE}") | ||||
434 | endif() | ||||
435 | endif() | ||||
436 | foreach(_source IN LISTS _sources) | ||||
437 | # concat sources separated by a break, it is no issue that first has also a leading break | ||||
438 | set(ECM_DOXYGENQCH_INPUT "${ECM_DOXYGENQCH_INPUT} \\\n\"${_source}\"") | ||||
439 | endforeach() | ||||
440 | set(ECM_DOXYGENQCH_FILE_PATTERNS "") | ||||
441 | endif() | ||||
442 | | ||||
443 | set(ECM_DOXYGENQCH_PROJECTNAME ${ARGS_OUTPUT_BASENAME}) | ||||
444 | file(RELATIVE_PATH _builddirrelative_filepath "${_apidox_builddir}/html" ${_qch_buildpath}) | ||||
445 | set(ECM_DOXYGENQCH_FILEPATH "\"${_builddirrelative_filepath}\"") | ||||
446 | set(ECM_DOXYGENQCH_PROJECTVERSION ${ARGS_VERSION}) | ||||
447 | set(ECM_DOXYGENQCH_VIRTUALFOLDER "${ARGS_OUTPUT_BASENAME}") | ||||
448 | set(ECM_DOXYGENQCH_FULLNAMESPACE ${_versioned_namespace}) | ||||
449 | set(ECM_DOXYGENQCH_BLANK_MACROS) | ||||
450 | foreach(_macro IN LISTS ARGS_BLANK_MACROS) | ||||
451 | # concat dirs separated by a break, it is no issue that first has also a leading break | ||||
452 | set(ECM_DOXYGENQCH_BLANK_MACROS "${ECM_DOXYGENQCH_BLANK_MACROS} \\\n${_macro}=\"\"") | ||||
453 | endforeach() | ||||
454 | set(ECM_DOXYGENQCH_TAGFILES) | ||||
455 | foreach(_versioned_postfix "" "_VERSIONED") | ||||
456 | foreach(_link_qch IN LISTS ARGS_LINK_QCHS${_versioned_postfix}) | ||||
457 | set(_target_usable TRUE) | ||||
458 | if (NOT TARGET ${_link_qch}) | ||||
459 | message(STATUS "No such target ${_link_qch} defined when calling kreport_add_qch().") | ||||
460 | set(_target_usable FALSE) | ||||
461 | elseif() | ||||
462 | foreach(_propertyname | ||||
463 | DOXYGEN_TAGFILE | ||||
464 | QHP_NAMESPACE${_versioned_postfix} | ||||
465 | QHP_VIRTUALFOLDER | ||||
466 | ) | ||||
467 | if(NOT "${_property}") | ||||
468 | message(STATUS "No property ${_propertyname} set on ${_link_qch} when calling kreport_add_qch().") | ||||
469 | set(_target_usable FALSE) | ||||
470 | endif() | ||||
471 | endforeach() | ||||
472 | endif() | ||||
473 | if(_target_usable) | ||||
474 | list(APPEND _dep_qch_targets ${_link_qch}) | ||||
475 | get_target_property(_link_qch_tagfile ${_link_qch} DOXYGEN_TAGFILE) | ||||
476 | get_target_property(_link_qch_tagfile_build ${_link_qch} DOXYGEN_TAGFILE_BUILD) | ||||
477 | get_target_property(_link_qch_namespace ${_link_qch} QHP_NAMESPACE${_versioned_postfix}) | ||||
478 | get_target_property(_link_qch_virtualfolder ${_link_qch} QHP_VIRTUALFOLDER) | ||||
479 | # if same build, then prefer build version over any installed one | ||||
480 | if (${_link_qch_tagfile_build}) | ||||
481 | set(_link_qch_tagfile ${_link_qch_tagfile_build}) | ||||
482 | list(APPEND _dep_tagfiles "${_link_qch_tagfile}") | ||||
483 | endif() | ||||
484 | set(_tagfile_entry "\"${_link_qch_tagfile}=qthelp://${_link_qch_namespace}/${_link_qch_virtualfolder}/\"") | ||||
485 | # concat dirs separated by a break, it is no issue that first has also a leading break | ||||
486 | set(ECM_DOXYGENQCH_TAGFILES "${ECM_DOXYGENQCH_TAGFILES} \\\n${_tagfile_entry}") | ||||
487 | else() | ||||
488 | message(WARNING "No linking to API dox of ${_link_qch}.") | ||||
489 | endif() | ||||
490 | endforeach() | ||||
491 | endforeach() | ||||
492 | | ||||
493 | set(ECM_DOXYGENQCH_WARN_LOGFILE "\"${_doxygenconfig_file}.log\"") | ||||
494 | if(ARGS_VERBOSE) | ||||
495 | set(ECM_DOXYGENQCH_QUIET "NO") | ||||
496 | else() | ||||
497 | set(ECM_DOXYGENQCH_QUIET "YES") | ||||
498 | endif() | ||||
499 | set(ECM_DOXYGENQCH_PERL_EXECUTABLE "${PERL_EXECUTABLE}") | ||||
500 | | ||||
501 | if (NOT DOXYGEN_FOUND) | ||||
502 | message(WARNING "Unable to find the doxygen utility - API dox QCH file will not be generated!") | ||||
503 | elseif(NOT ECM_DOXYGENQCH_QHELPGENERATOR_EXECUTABLE) | ||||
504 | message(WARNING "Unable to find the qhelpgenerator utility - API dox QCH file will not be generated!") | ||||
505 | elseif(NOT PERL_FOUND) | ||||
506 | message(WARNING "Unable to find the perl utility - API dox QCH file will not be generated!") | ||||
507 | else() | ||||
508 | configure_file( | ||||
509 | "${_doxygenconfig_template_file}" | ||||
510 | "${_doxygenconfig_file}" | ||||
511 | @ONLY | ||||
512 | ) | ||||
513 | | ||||
514 | set(_qch_INSTALLPATH ${ARGS_QCH_INSTALL_DESTINATION}) | ||||
515 | set(_tags_INSTALLPATH ${ARGS_TAGFILE_INSTALL_DESTINATION}) | ||||
516 | file(RELATIVE_PATH _relative_qch_file ${CMAKE_BINARY_DIR} ${_qch_buildpath}) | ||||
517 | file(RELATIVE_PATH _relative_tags_file ${CMAKE_BINARY_DIR} ${_tags_buildpath}) | ||||
518 | add_custom_command( | ||||
519 | OUTPUT ${_qch_buildpath} ${_tags_buildpath} | ||||
520 | COMMENT "Generating ${_relative_qch_file}, ${_relative_tags_file}" | ||||
521 | COMMAND cmake -E remove_directory "${ECM_DOXYGENQCH_OUTPUTDIR}" | ||||
522 | COMMAND cmake -E make_directory "${ECM_DOXYGENQCH_OUTPUTDIR}" | ||||
523 | COMMAND ${DOXYGEN_EXECUTABLE} "${_doxygenconfig_file}" | ||||
524 | DEPENDS ${_doxygenconfig_file} ${_sources} ${_dep_tagfiles} ${_dep_qch_targets} | ||||
525 | ) | ||||
526 | add_custom_target(${target_name} ALL DEPENDS ${_qch_buildpath} ${_tags_buildpath}) | ||||
527 | set_target_properties(${target_name} PROPERTIES | ||||
528 | DOXYGEN_TAGFILE "${_qch_INSTALLPATH}/${_tags_file_basename}" | ||||
529 | DOXYGEN_TAGFILE_BUILD "${_tags_buildpath}" | ||||
530 | QHP_NAMESPACE "${_namespace}" | ||||
531 | QHP_NAMESPACE_VERSIONED "${_versioned_namespace}" | ||||
532 | QHP_VIRTUALFOLDER "${ECM_DOXYGENQCH_VIRTUALFOLDER}" | ||||
533 | ) | ||||
534 | | ||||
535 | install(FILES | ||||
536 | ${_qch_buildpath} | ||||
537 | DESTINATION ${_qch_INSTALLPATH} | ||||
538 | COMPONENT Devel | ||||
539 | ) | ||||
540 | | ||||
541 | install(FILES | ||||
542 | ${_tags_buildpath} | ||||
543 | DESTINATION ${_tags_INSTALLPATH} | ||||
544 | COMPONENT Devel | ||||
545 | ) | ||||
546 | endif() | ||||
547 | | ||||
548 | endfunction() | ||||
549 | | ||||
550 | | ||||
551 | function(kreport_install_qch_export) | ||||
552 | set(options ) | ||||
553 | set(oneValueArgs FILE DESTINATION COMPONENT) | ||||
554 | set(multiValueArgs TARGETS) | ||||
555 | | ||||
556 | cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) | ||||
557 | | ||||
558 | if(NOT DEFINED ARGS_FILE) | ||||
559 | message(FATAL_ERROR "FILE needs to be defined when calling kreport_install_qch_export().") | ||||
560 | endif() | ||||
561 | | ||||
562 | if(NOT DEFINED ARGS_DESTINATION) | ||||
563 | message(FATAL_ERROR "DESTINATION needs to be defined when calling kreport_install_qch_export().") | ||||
564 | endif() | ||||
565 | | ||||
566 | # TARGETS may be empty (and ARGS_TARGETS will not be defined then by cmake_parse_arguments) | ||||
567 | | ||||
568 | set(_content | ||||
569 | "# Generated by kreport_install_qch_export() | ||||
570 | # Any changes to this file will be overwritten by the next CMake run. | ||||
571 | " | ||||
572 | ) | ||||
573 | | ||||
574 | foreach(_target IN LISTS ARGS_TARGETS) | ||||
575 | set(_target_usable TRUE) | ||||
576 | | ||||
577 | if (NOT TARGET ${_target}) | ||||
578 | message(STATUS "No such target ${_target} when calling kreport_install_qch_export().") | ||||
579 | set(_target_usable FALSE) | ||||
580 | else() | ||||
581 | foreach(_propertyname | ||||
582 | DOXYGEN_TAGFILE | ||||
583 | QHP_NAMESPACE | ||||
584 | QHP_NAMESPACE_VERSIONED | ||||
585 | QHP_VIRTUALFOLDER | ||||
586 | ) | ||||
587 | get_target_property(_property ${_target} ${_propertyname}) | ||||
588 | if(NOT _property) | ||||
589 | message(STATUS "No property ${_propertyname} set on ${_target} when calling kreport_install_qch_export(). <${_property}>") | ||||
590 | set(_target_usable FALSE) | ||||
591 | endif() | ||||
592 | endforeach() | ||||
593 | endif() | ||||
594 | if(_target_usable) | ||||
595 | get_target_property(_tagfile ${_target} DOXYGEN_TAGFILE) | ||||
596 | get_target_property(_namespace ${_target} QHP_NAMESPACE) | ||||
597 | get_target_property(_namespace_versioned ${_target} QHP_NAMESPACE_VERSIONED) | ||||
598 | get_target_property(_virtualfolder ${_target} QHP_VIRTUALFOLDER) | ||||
599 | set(_content "${_content} | ||||
600 | if (NOT TARGET ${_target}) | ||||
601 | | ||||
602 | add_custom_target(${_target}) | ||||
603 | set_target_properties(${_target} PROPERTIES | ||||
604 | DOXYGEN_TAGFILE \"${_tagfile}\" | ||||
605 | QHP_NAMESPACE \"${_namespace}\" | ||||
606 | QHP_NAMESPACE_VERSIONED \"${_namespace_versioned}\" | ||||
607 | QHP_VIRTUALFOLDER \"${_virtualfolder}\" | ||||
608 | IMPORTED TRUE | ||||
609 | ) | ||||
610 | | ||||
611 | endif() | ||||
612 | " | ||||
613 | ) | ||||
614 | else() | ||||
615 | message(STATUS "No target exported for ${_target}.") | ||||
616 | endif() | ||||
617 | endforeach() | ||||
618 | | ||||
619 | if (NOT IS_ABSOLUTE ${ARGS_FILE}) | ||||
620 | set(ARGS_FILE "${CMAKE_CURRENT_BINARY_DIR}/${ARGS_FILE}") | ||||
621 | endif() | ||||
622 | | ||||
623 | file(GENERATE | ||||
624 | OUTPUT "${ARGS_FILE}" | ||||
625 | CONTENT "${_content}" | ||||
626 | ) | ||||
627 | | ||||
628 | if (DEFINED ARGS_COMPONENT) | ||||
629 | set(_component COMPONENT ${ARGS_COMPONENT}) | ||||
630 | endif() | ||||
631 | install( | ||||
632 | FILES "${ARGS_FILE}" | ||||
633 | DESTINATION "${ARGS_DESTINATION}" | ||||
634 | ${_component} | ||||
635 | ) | ||||
636 | | ||||
637 | endfunction() |