FindDoxygen.cmake 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #[=======================================================================[.rst:
  4. FindDoxygen
  5. -----------
  6. Doxygen is a documentation generation tool (see https://www.doxygen.nl).
  7. This module looks for Doxygen and some optional tools it supports:
  8. ``dot``
  9. `Graphviz <https://graphviz.org>`_ ``dot`` utility used to render various
  10. graphs.
  11. ``mscgen``
  12. `Message Chart Generator <https://www.mcternan.me.uk/mscgen/>`_ utility used
  13. by Doxygen's ``\msc`` and ``\mscfile`` commands.
  14. ``dia``
  15. `Dia <https://wiki.gnome.org/Apps/Dia>`_ the diagram editor used by Doxygen's
  16. ``\diafile`` command.
  17. .. versionadded:: 3.9
  18. These tools are available as components in the :command:`find_package` command.
  19. For example:
  20. .. code-block:: cmake
  21. # Require dot, treat the other components as optional
  22. find_package(Doxygen
  23. REQUIRED dot
  24. OPTIONAL_COMPONENTS mscgen dia)
  25. The following variables are defined by this module:
  26. .. variable:: DOXYGEN_FOUND
  27. True if the ``doxygen`` executable was found.
  28. .. variable:: DOXYGEN_VERSION
  29. The version reported by ``doxygen --version``.
  30. .. versionadded:: 3.9
  31. The module defines ``IMPORTED`` targets for Doxygen and each component found.
  32. These can be used as part of custom commands, etc. and should be preferred over
  33. old-style (and now deprecated) variables like ``DOXYGEN_EXECUTABLE``. The
  34. following import targets are defined if their corresponding executable could be
  35. found (the component import targets will only be defined if that component was
  36. requested):
  37. ::
  38. Doxygen::doxygen
  39. Doxygen::dot
  40. Doxygen::mscgen
  41. Doxygen::dia
  42. Functions
  43. ^^^^^^^^^
  44. .. command:: doxygen_add_docs
  45. .. versionadded:: 3.9
  46. This function is intended as a convenience for adding a target for generating
  47. documentation with Doxygen. It aims to provide sensible defaults so that
  48. projects can generally just provide the input files and directories and that
  49. will be sufficient to give sensible results. The function supports the
  50. ability to customize the Doxygen configuration used to build the
  51. documentation.
  52. ::
  53. doxygen_add_docs(targetName
  54. [filesOrDirs...]
  55. [ALL]
  56. [USE_STAMP_FILE]
  57. [WORKING_DIRECTORY dir]
  58. [COMMENT comment]
  59. [CONFIG_FILE filename])
  60. The function constructs a ``Doxyfile`` and defines a custom target that runs
  61. Doxygen on that generated file. The listed files and directories are used as
  62. the ``INPUT`` of the generated ``Doxyfile`` and they can contain wildcards.
  63. Any files that are listed explicitly will also be added as ``SOURCES`` of the
  64. custom target so they will show up in an IDE project's source list.
  65. So that relative input paths work as expected, by default the working
  66. directory of the Doxygen command will be the current source directory (i.e.
  67. :variable:`CMAKE_CURRENT_SOURCE_DIR`). This can be overridden with the
  68. ``WORKING_DIRECTORY`` option to change the directory used as the relative
  69. base point. Note also that Doxygen's default behavior is to strip the working
  70. directory from relative paths in the generated documentation (see the
  71. ``STRIP_FROM_PATH`` `Doxygen config option
  72. <https://www.doxygen.nl/manual/config.html>`_ for details).
  73. If provided, the optional ``comment`` will be passed as the ``COMMENT`` for
  74. the :command:`add_custom_target` command used to create the custom target
  75. internally.
  76. .. versionadded:: 3.27
  77. If ``CONFIG_FILE`` is set, the given file provided with full-path
  78. will be used as doxygen configuration file
  79. .. versionadded:: 3.12
  80. If ``ALL`` is set, the target will be added to the default build target.
  81. .. versionadded:: 3.16
  82. If ``USE_STAMP_FILE`` is set, the custom command defined by this function will
  83. create a stamp file with the name ``<targetName>.stamp`` in the current
  84. binary directory whenever doxygen is re-run. With this option present, all
  85. items in ``<filesOrDirs>`` must be files (i.e. no directories, symlinks or
  86. wildcards) and each of the files must exist at the time
  87. ``doxygen_add_docs()`` is called. An error will be raised if any of the
  88. items listed is missing or is not a file when ``USE_STAMP_FILE`` is given.
  89. A dependency will be created on each of the files so that doxygen will only
  90. be re-run if one of the files is updated. Without the ``USE_STAMP_FILE``
  91. option, doxygen will always be re-run if the ``<targetName>`` target is built
  92. regardless of whether anything listed in ``<filesOrDirs>`` has changed.
  93. The contents of the generated ``Doxyfile`` can be customized by setting CMake
  94. variables before calling ``doxygen_add_docs()``. Any variable with a name of
  95. the form ``DOXYGEN_<tag>`` will have its value substituted for the
  96. corresponding ``<tag>`` configuration option in the ``Doxyfile``. See the
  97. `Doxygen documentation <https://www.doxygen.nl/manual/config.html>`_ for the
  98. full list of supported configuration options.
  99. Some of Doxygen's defaults are overridden to provide more appropriate
  100. behavior for a CMake project. Each of the following will be explicitly set
  101. unless the variable already has a value before ``doxygen_add_docs()`` is
  102. called (with some exceptions noted):
  103. .. variable:: DOXYGEN_HAVE_DOT
  104. Set to ``YES`` if the ``dot`` component was requested and it was found,
  105. ``NO`` otherwise. Any existing value of ``DOXYGEN_HAVE_DOT`` is ignored.
  106. .. variable:: DOXYGEN_DOT_MULTI_TARGETS
  107. Set to ``YES`` by this module (note that this requires a ``dot`` version
  108. newer than 1.8.10). This option is only meaningful if ``DOXYGEN_HAVE_DOT``
  109. is also set to ``YES``.
  110. .. variable:: DOXYGEN_GENERATE_LATEX
  111. Set to ``NO`` by this module.
  112. .. variable:: DOXYGEN_WARN_FORMAT
  113. For Visual Studio based generators, this is set to the form recognized by
  114. the Visual Studio IDE: ``$file($line) : $text``. For all other generators,
  115. Doxygen's default value is not overridden.
  116. .. variable:: DOXYGEN_PROJECT_NAME
  117. Populated with the name of the current project (i.e.
  118. :variable:`PROJECT_NAME`).
  119. .. variable:: DOXYGEN_PROJECT_NUMBER
  120. Populated with the version of the current project (i.e.
  121. :variable:`PROJECT_VERSION`).
  122. .. variable:: DOXYGEN_PROJECT_BRIEF
  123. Populated with the description of the current project (i.e.
  124. :variable:`PROJECT_DESCRIPTION`).
  125. .. variable:: DOXYGEN_INPUT
  126. Projects should not set this variable. It will be populated with the set of
  127. files and directories passed to ``doxygen_add_docs()``, thereby providing
  128. consistent behavior with the other built-in commands like
  129. :command:`add_executable`, :command:`add_library` and
  130. :command:`add_custom_target`. If a variable named ``DOXYGEN_INPUT`` is set
  131. by the project, it will be ignored and a warning will be issued.
  132. .. variable:: DOXYGEN_RECURSIVE
  133. Set to ``YES`` by this module.
  134. .. variable:: DOXYGEN_EXCLUDE_PATTERNS
  135. If the set of inputs includes directories, this variable will specify
  136. patterns used to exclude files from them. The following patterns are added
  137. by ``doxygen_add_docs()`` to ensure CMake-specific files and directories
  138. are not included in the input. If the project sets
  139. ``DOXYGEN_EXCLUDE_PATTERNS``, those contents are merged with these
  140. additional patterns rather than replacing them:
  141. ::
  142. */.git/*
  143. */.svn/*
  144. */.hg/*
  145. */CMakeFiles/*
  146. */_CPack_Packages/*
  147. DartConfiguration.tcl
  148. CMakeLists.txt
  149. CMakeCache.txt
  150. .. variable:: DOXYGEN_OUTPUT_DIRECTORY
  151. Set to :variable:`CMAKE_CURRENT_BINARY_DIR` by this module. Note that if
  152. the project provides its own value for this and it is a relative path, it
  153. will be converted to an absolute path relative to the current binary
  154. directory. This is necessary because doxygen will normally be run from a
  155. directory within the source tree so that relative source paths work as
  156. expected. If this directory does not exist, it will be recursively created
  157. prior to executing the doxygen commands.
  158. To change any of these defaults or override any other Doxygen config option,
  159. set relevant variables before calling ``doxygen_add_docs()``. For example:
  160. .. code-block:: cmake
  161. set(DOXYGEN_GENERATE_HTML NO)
  162. set(DOXYGEN_GENERATE_MAN YES)
  163. doxygen_add_docs(
  164. doxygen
  165. ${PROJECT_SOURCE_DIR}
  166. COMMENT "Generate man pages"
  167. )
  168. A number of Doxygen config options accept lists of values, but Doxygen requires
  169. them to be separated by whitespace. CMake variables hold lists as a string with
  170. items separated by semi-colons, so a conversion needs to be performed. The
  171. ``doxygen_add_docs()`` command specifically checks the following Doxygen config
  172. options and will convert their associated CMake variable's contents into the
  173. required form if set. CMake variables are named ``DOXYGEN_<name>`` for the
  174. Doxygen settings specified here.
  175. ::
  176. ABBREVIATE_BRIEF
  177. ALIASES
  178. CITE_BIB_FILES
  179. DIAFILE_DIRS
  180. DOTFILE_DIRS
  181. DOT_FONTPATH
  182. ENABLED_SECTIONS
  183. EXAMPLE_PATH
  184. EXAMPLE_PATTERNS
  185. EXCLUDE
  186. EXCLUDE_PATTERNS
  187. EXCLUDE_SYMBOLS
  188. EXPAND_AS_DEFINED
  189. EXTENSION_MAPPING
  190. EXTRA_PACKAGES
  191. EXTRA_SEARCH_MAPPINGS
  192. FILE_PATTERNS
  193. FILTER_PATTERNS
  194. FILTER_SOURCE_PATTERNS
  195. HTML_EXTRA_FILES
  196. HTML_EXTRA_STYLESHEET
  197. IGNORE_PREFIX
  198. IMAGE_PATH
  199. INCLUDE_FILE_PATTERNS
  200. INCLUDE_PATH
  201. INPUT
  202. LATEX_EXTRA_FILES
  203. LATEX_EXTRA_STYLESHEET
  204. MATHJAX_EXTENSIONS
  205. MSCFILE_DIRS
  206. PLANTUML_INCLUDE_PATH
  207. PREDEFINED
  208. QHP_CUST_FILTER_ATTRS
  209. QHP_SECT_FILTER_ATTRS
  210. STRIP_FROM_INC_PATH
  211. STRIP_FROM_PATH
  212. TAGFILES
  213. TCL_SUBST
  214. The following single value Doxygen options will be quoted automatically
  215. if they contain at least one space:
  216. ::
  217. CHM_FILE
  218. DIA_PATH
  219. DOCBOOK_OUTPUT
  220. DOCSET_FEEDNAME
  221. DOCSET_PUBLISHER_NAME
  222. DOT_FONTNAME
  223. DOT_PATH
  224. EXTERNAL_SEARCH_ID
  225. FILE_VERSION_FILTER
  226. GENERATE_TAGFILE
  227. HHC_LOCATION
  228. HTML_FOOTER
  229. HTML_HEADER
  230. HTML_OUTPUT
  231. HTML_STYLESHEET
  232. INPUT_FILTER
  233. LATEX_FOOTER
  234. LATEX_HEADER
  235. LATEX_OUTPUT
  236. LAYOUT_FILE
  237. MAN_OUTPUT
  238. MAN_SUBDIR
  239. MATHJAX_CODEFILE
  240. MSCGEN_PATH
  241. OUTPUT_DIRECTORY
  242. PERL_PATH
  243. PLANTUML_JAR_PATH
  244. PROJECT_BRIEF
  245. PROJECT_LOGO
  246. PROJECT_NAME
  247. QCH_FILE
  248. QHG_LOCATION
  249. QHP_CUST_FILTER_NAME
  250. QHP_VIRTUAL_FOLDER
  251. RTF_EXTENSIONS_FILE
  252. RTF_OUTPUT
  253. RTF_STYLESHEET_FILE
  254. SEARCHDATA_FILE
  255. USE_MDFILE_AS_MAINPAGE
  256. WARN_FORMAT
  257. WARN_LOGFILE
  258. XML_OUTPUT
  259. .. versionadded:: 3.11
  260. There are situations where it may be undesirable for a particular config option
  261. to be automatically quoted by ``doxygen_add_docs()``, such as ``ALIASES`` which
  262. may need to include its own embedded quoting. The ``DOXYGEN_VERBATIM_VARS``
  263. variable can be used to specify a list of Doxygen variables (including the
  264. leading ``DOXYGEN_`` prefix) which should not be quoted. The project is then
  265. responsible for ensuring that those variables' values make sense when placed
  266. directly in the Doxygen input file. In the case of list variables, list items
  267. are still separated by spaces, it is only the automatic quoting that is
  268. skipped. For example, the following allows ``doxygen_add_docs()`` to apply
  269. quoting to ``DOXYGEN_PROJECT_BRIEF``, but not each item in the
  270. ``DOXYGEN_ALIASES`` list (:ref:`bracket syntax <Bracket Argument>` can also
  271. be used to make working with embedded quotes easier):
  272. .. code-block:: cmake
  273. set(DOXYGEN_PROJECT_BRIEF "String with spaces")
  274. set(DOXYGEN_ALIASES
  275. [[somealias="@some_command param"]]
  276. "anotherAlias=@foobar"
  277. )
  278. set(DOXYGEN_VERBATIM_VARS DOXYGEN_ALIASES)
  279. The resultant ``Doxyfile`` will contain the following lines:
  280. .. code-block:: text
  281. PROJECT_BRIEF = "String with spaces"
  282. ALIASES = somealias="@some_command param" anotherAlias=@foobar
  283. Deprecated Result Variables
  284. ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  285. .. deprecated:: 3.9
  286. For compatibility with previous versions of CMake, the following variables
  287. are also defined but they are deprecated and should no longer be used:
  288. .. variable:: DOXYGEN_EXECUTABLE
  289. The path to the ``doxygen`` command. If projects need to refer to the
  290. ``doxygen`` executable directly, they should use the ``Doxygen::doxygen``
  291. import target instead.
  292. .. variable:: DOXYGEN_DOT_FOUND
  293. True if the ``dot`` executable was found.
  294. .. variable:: DOXYGEN_DOT_EXECUTABLE
  295. The path to the ``dot`` command. If projects need to refer to the ``dot``
  296. executable directly, they should use the ``Doxygen::dot`` import target
  297. instead.
  298. .. variable:: DOXYGEN_DOT_PATH
  299. The path to the directory containing the ``dot`` executable as reported in
  300. ``DOXYGEN_DOT_EXECUTABLE``. The path may have forward slashes even on Windows
  301. and is not suitable for direct substitution into a ``Doxyfile.in`` template.
  302. If you need this value, get the :prop_tgt:`IMPORTED_LOCATION` property of the
  303. ``Doxygen::dot`` target and use :command:`get_filename_component` to extract
  304. the directory part of that path. You may also want to consider using
  305. :command:`file(TO_NATIVE_PATH)` to prepare the path for a Doxygen
  306. configuration file.
  307. Deprecated Hint Variables
  308. ^^^^^^^^^^^^^^^^^^^^^^^^^
  309. .. deprecated:: 3.9
  310. .. variable:: DOXYGEN_SKIP_DOT
  311. This variable has no effect for the component form of ``find_package``.
  312. In backward compatibility mode (i.e. without components list) it prevents
  313. the finder module from searching for Graphviz's ``dot`` utility.
  314. #]=======================================================================]
  315. # For backwards compatibility support
  316. if(Doxygen_FIND_QUIETLY)
  317. set(DOXYGEN_FIND_QUIETLY TRUE)
  318. endif()
  319. # ===== Rationale for OS X AppBundle mods below =====
  320. # With the OS X GUI version, Doxygen likes to be installed to /Applications
  321. # and it contains the doxygen executable in the bundle. In the versions I've
  322. # seen, it is located in Resources, but in general, more often binaries are
  323. # located in MacOS.
  324. #
  325. # NOTE: The official Doxygen.app distributed for OS X uses non-standard
  326. # conventions. Instead of the command-line "doxygen" tool being placed in
  327. # Doxygen.app/Contents/MacOS, "Doxywizard" is placed there instead and
  328. # "doxygen" is placed in Contents/Resources. This is most likely done
  329. # so that something happens when people double-click on the Doxygen.app
  330. # package. Unfortunately, CMake gets confused by this as when it sees the
  331. # bundle it uses "Doxywizard" as the executable to use instead of
  332. # "doxygen". Therefore to work-around this issue we temporarily disable
  333. # the app-bundle feature, just for this CMake module:
  334. #
  335. if(APPLE)
  336. # Save the old setting
  337. set(TEMP_DOXYGEN_SAVE_CMAKE_FIND_APPBUNDLE ${CMAKE_FIND_APPBUNDLE})
  338. # Disable the App-bundle detection feature
  339. set(CMAKE_FIND_APPBUNDLE "NEVER")
  340. endif()
  341. # FYI:
  342. # In older versions of OS X Doxygen, dot was included with the Doxygen bundle,
  343. # but newer versions require you to download Graphviz.app which contains "dot"
  344. # or use something like homebrew.
  345. # ============== End OSX stuff ================
  346. include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
  347. #
  348. # Find Doxygen...
  349. #
  350. function(_Doxygen_get_version doxy_version result_var doxy_path)
  351. execute_process(
  352. COMMAND "${doxy_path}" --version
  353. OUTPUT_VARIABLE full_doxygen_version
  354. OUTPUT_STRIP_TRAILING_WHITESPACE
  355. RESULT_VARIABLE version_result
  356. )
  357. # Ignore any commit hashes, etc.
  358. string(REGEX MATCH [[^[0-9]+\.[0-9]+\.[0-9]+]] sem_doxygen_version "${full_doxygen_version}")
  359. set(${result_var} ${version_result} PARENT_SCOPE)
  360. set(${doxy_version} ${sem_doxygen_version} PARENT_SCOPE)
  361. endfunction()
  362. function(_Doxygen_version_validator version_match doxy_path)
  363. if(NOT DEFINED Doxygen_FIND_VERSION)
  364. set(${is_valid_version} TRUE PARENT_SCOPE)
  365. else()
  366. _Doxygen_get_version(candidate_version version_result "${doxy_path}")
  367. find_package_check_version("${candidate_version}" valid_doxy_version
  368. HANDLE_VERSION_RANGE
  369. )
  370. set(${version_match} "${valid_doxy_version}" PARENT_SCOPE)
  371. endif()
  372. endfunction()
  373. macro(_Doxygen_find_doxygen)
  374. find_program(
  375. DOXYGEN_EXECUTABLE
  376. NAMES doxygen
  377. PATHS
  378. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\doxygen_is1;Inno Setup: App Path]/bin"
  379. /Applications/Doxygen.app/Contents/Resources
  380. /Applications/Doxygen.app/Contents/MacOS
  381. /Applications/Utilities/Doxygen.app/Contents/Resources
  382. /Applications/Utilities/Doxygen.app/Contents/MacOS
  383. DOC "Doxygen documentation generation tool (https://www.doxygen.nl)"
  384. VALIDATOR _Doxygen_version_validator
  385. )
  386. mark_as_advanced(DOXYGEN_EXECUTABLE)
  387. if(DOXYGEN_EXECUTABLE)
  388. _Doxygen_get_version(DOXYGEN_VERSION _Doxygen_version_result "${DOXYGEN_EXECUTABLE}")
  389. if(_Doxygen_version_result)
  390. if(NOT Doxygen_FIND_QUIETLY)
  391. message(WARNING "Doxygen executable failed unexpected while determining version (exit status: ${_Doxygen_version_result}). Disabling Doxygen.")
  392. endif()
  393. set(DOXYGEN_EXECUTABLE "${DOXYGEN_EXECUTABLE}-FAILED_EXECUTION-NOTFOUND")
  394. else()
  395. # Create an imported target for Doxygen
  396. if(NOT TARGET Doxygen::doxygen)
  397. add_executable(Doxygen::doxygen IMPORTED GLOBAL)
  398. set_target_properties(Doxygen::doxygen PROPERTIES
  399. IMPORTED_LOCATION "${DOXYGEN_EXECUTABLE}"
  400. )
  401. endif()
  402. endif()
  403. endif()
  404. endmacro()
  405. #
  406. # Find Diagram Editor...
  407. #
  408. macro(_Doxygen_find_dia)
  409. set(_x86 "(x86)")
  410. find_program(
  411. DOXYGEN_DIA_EXECUTABLE
  412. NAMES dia
  413. PATHS
  414. "$ENV{ProgramFiles}/Dia"
  415. "$ENV{ProgramFiles${_x86}}/Dia"
  416. DOC "Diagram Editor tool for use with Doxygen"
  417. )
  418. mark_as_advanced(DOXYGEN_DIA_EXECUTABLE)
  419. if(DOXYGEN_DIA_EXECUTABLE)
  420. # The Doxyfile wants the path to the utility, not the entire path
  421. # including file name
  422. get_filename_component(DOXYGEN_DIA_PATH
  423. "${DOXYGEN_DIA_EXECUTABLE}"
  424. DIRECTORY)
  425. if(WIN32)
  426. file(TO_NATIVE_PATH "${DOXYGEN_DIA_PATH}" DOXYGEN_DIA_PATH)
  427. endif()
  428. # Create an imported target for component
  429. if(NOT TARGET Doxygen::dia)
  430. add_executable(Doxygen::dia IMPORTED GLOBAL)
  431. set_target_properties(Doxygen::dia PROPERTIES
  432. IMPORTED_LOCATION "${DOXYGEN_DIA_EXECUTABLE}"
  433. )
  434. endif()
  435. endif()
  436. unset(_x86)
  437. endmacro()
  438. #
  439. # Find Graphviz Dot...
  440. #
  441. macro(_Doxygen_find_dot)
  442. if(WIN32)
  443. set(_x86 "(x86)")
  444. file(
  445. GLOB _Doxygen_GRAPHVIZ_BIN_DIRS
  446. "$ENV{ProgramFiles}/Graphviz*/bin"
  447. "$ENV{ProgramFiles${_x86}}/Graphviz*/bin"
  448. )
  449. unset(_x86)
  450. else()
  451. set(_Doxygen_GRAPHVIZ_BIN_DIRS "")
  452. endif()
  453. find_program(
  454. DOXYGEN_DOT_EXECUTABLE
  455. NAMES dot
  456. PATHS
  457. ${_Doxygen_GRAPHVIZ_BIN_DIRS}
  458. "$ENV{ProgramFiles}/ATT/Graphviz/bin"
  459. "C:/Program Files/ATT/Graphviz/bin"
  460. [HKEY_LOCAL_MACHINE\\SOFTWARE\\ATT\\Graphviz;InstallPath]/bin
  461. /Applications/Graphviz.app/Contents/MacOS
  462. /Applications/Utilities/Graphviz.app/Contents/MacOS
  463. /Applications/Doxygen.app/Contents/Resources
  464. /Applications/Doxygen.app/Contents/MacOS
  465. /Applications/Utilities/Doxygen.app/Contents/Resources
  466. /Applications/Utilities/Doxygen.app/Contents/MacOS
  467. DOC "Dot tool for use with Doxygen"
  468. )
  469. mark_as_advanced(DOXYGEN_DOT_EXECUTABLE)
  470. if(DOXYGEN_DOT_EXECUTABLE)
  471. # The Doxyfile wants the path to the utility, not the entire path
  472. # including file name
  473. get_filename_component(DOXYGEN_DOT_PATH
  474. "${DOXYGEN_DOT_EXECUTABLE}"
  475. DIRECTORY)
  476. if(WIN32)
  477. file(TO_NATIVE_PATH "${DOXYGEN_DOT_PATH}" DOXYGEN_DOT_PATH)
  478. endif()
  479. # Create an imported target for component
  480. if(NOT TARGET Doxygen::dot)
  481. add_executable(Doxygen::dot IMPORTED GLOBAL)
  482. set_target_properties(Doxygen::dot PROPERTIES
  483. IMPORTED_LOCATION "${DOXYGEN_DOT_EXECUTABLE}"
  484. )
  485. endif()
  486. endif()
  487. unset(_Doxygen_GRAPHVIZ_BIN_DIRS)
  488. endmacro()
  489. #
  490. # Find Message Sequence Chart...
  491. #
  492. macro(_Doxygen_find_mscgen)
  493. set(_x86 "(x86)")
  494. find_program(
  495. DOXYGEN_MSCGEN_EXECUTABLE
  496. NAMES mscgen
  497. PATHS
  498. "$ENV{ProgramFiles}/Mscgen"
  499. "$ENV{ProgramFiles${_x86}}/Mscgen"
  500. DOC "Message sequence chart tool for use with Doxygen"
  501. )
  502. mark_as_advanced(DOXYGEN_MSCGEN_EXECUTABLE)
  503. if(DOXYGEN_MSCGEN_EXECUTABLE)
  504. # The Doxyfile wants the path to the utility, not the entire path
  505. # including file name
  506. get_filename_component(DOXYGEN_MSCGEN_PATH
  507. "${DOXYGEN_MSCGEN_EXECUTABLE}"
  508. DIRECTORY)
  509. if(WIN32)
  510. file(TO_NATIVE_PATH "${DOXYGEN_MSCGEN_PATH}" DOXYGEN_MSCGEN_PATH)
  511. endif()
  512. # Create an imported target for component
  513. if(NOT TARGET Doxygen::mscgen)
  514. add_executable(Doxygen::mscgen IMPORTED GLOBAL)
  515. set_target_properties(Doxygen::mscgen PROPERTIES
  516. IMPORTED_LOCATION "${DOXYGEN_MSCGEN_EXECUTABLE}"
  517. )
  518. endif()
  519. endif()
  520. unset(_x86)
  521. endmacro()
  522. # Make sure `doxygen` is one of the components to find
  523. set(_Doxygen_keep_backward_compat FALSE)
  524. if(NOT Doxygen_FIND_COMPONENTS)
  525. # Search at least for `doxygen` executable
  526. set(Doxygen_FIND_COMPONENTS doxygen)
  527. # Preserve backward compatibility:
  528. # search for `dot` also if `DOXYGEN_SKIP_DOT` is not explicitly disable this.
  529. if(NOT DOXYGEN_SKIP_DOT)
  530. list(APPEND Doxygen_FIND_COMPONENTS dot)
  531. endif()
  532. set(_Doxygen_keep_backward_compat TRUE)
  533. elseif(NOT doxygen IN_LIST Doxygen_FIND_COMPONENTS)
  534. list(INSERT Doxygen_FIND_COMPONENTS 0 doxygen)
  535. endif()
  536. #
  537. # Find all requested components of Doxygen...
  538. #
  539. foreach(_comp IN LISTS Doxygen_FIND_COMPONENTS)
  540. if(_comp STREQUAL "doxygen")
  541. _Doxygen_find_doxygen()
  542. elseif(_comp STREQUAL "dia")
  543. _Doxygen_find_dia()
  544. elseif(_comp STREQUAL "dot")
  545. _Doxygen_find_dot()
  546. elseif(_comp STREQUAL "mscgen")
  547. _Doxygen_find_mscgen()
  548. else()
  549. message(WARNING "${_comp} is not a valid Doxygen component")
  550. set(Doxygen_${_comp}_FOUND FALSE)
  551. continue()
  552. endif()
  553. if(TARGET Doxygen::${_comp})
  554. set(Doxygen_${_comp}_FOUND TRUE)
  555. else()
  556. set(Doxygen_${_comp}_FOUND FALSE)
  557. endif()
  558. endforeach()
  559. unset(_comp)
  560. # Verify find results
  561. find_package_handle_standard_args(
  562. Doxygen
  563. REQUIRED_VARS DOXYGEN_EXECUTABLE
  564. VERSION_VAR DOXYGEN_VERSION
  565. HANDLE_VERSION_RANGE
  566. HANDLE_COMPONENTS
  567. )
  568. #
  569. # Backwards compatibility...
  570. #
  571. if(APPLE)
  572. # Restore the old app-bundle setting
  573. set(CMAKE_FIND_APPBUNDLE ${TEMP_DOXYGEN_SAVE_CMAKE_FIND_APPBUNDLE})
  574. endif()
  575. # Maintain the _FOUND variables as "YES" or "NO" for backwards
  576. # compatibility. This allows people to substitute them directly into
  577. # Doxyfile with configure_file().
  578. if(DOXYGEN_FOUND)
  579. set(DOXYGEN_FOUND "YES")
  580. else()
  581. set(DOXYGEN_FOUND "NO")
  582. endif()
  583. if(_Doxygen_keep_backward_compat)
  584. if(Doxygen_dot_FOUND)
  585. set(DOXYGEN_DOT_FOUND "YES")
  586. else()
  587. set(DOXYGEN_DOT_FOUND "NO")
  588. endif()
  589. # For backwards compatibility support for even older CMake versions
  590. set(DOXYGEN ${DOXYGEN_EXECUTABLE})
  591. set(DOT ${DOXYGEN_DOT_EXECUTABLE})
  592. # No need to keep any backward compatibility for `DOXYGEN_MSCGEN_XXX`
  593. # and `DOXYGEN_DIA_XXX` since they were not supported before component
  594. # support was added
  595. endif()
  596. unset(_Doxygen_keep_backward_compat)
  597. #
  598. # Allow full control of Doxygen from CMakeLists.txt
  599. #
  600. # Prepare a template Doxyfile and Doxygen's default values CMake file
  601. if(TARGET Doxygen::doxygen)
  602. # If doxygen was found, use it to generate a minimal default Doxyfile.
  603. # We will delete this file after we have finished using it below to
  604. # generate the other files that doxygen_add_docs() will use.
  605. set(_Doxygen_tpl "${CMAKE_BINARY_DIR}/CMakeDoxyfile.tpl")
  606. execute_process(
  607. COMMAND "${DOXYGEN_EXECUTABLE}" -s -g "${_Doxygen_tpl}"
  608. OUTPUT_QUIET
  609. RESULT_VARIABLE _Doxygen_tpl_result
  610. )
  611. if(_Doxygen_tpl_result)
  612. message(FATAL_ERROR
  613. "Unable to generate Doxyfile template: ${_Doxygen_tpl_result}")
  614. elseif(NOT EXISTS "${_Doxygen_tpl}")
  615. message(FATAL_ERROR
  616. "Doxygen has failed to generate a Doxyfile template")
  617. endif()
  618. # Write a do-not-edit header to files we are going to generate...
  619. set(_Doxygen_do_not_edit_header
  620. [[
  621. #
  622. # DO NOT EDIT! THIS FILE WAS GENERATED BY CMAKE!
  623. #
  624. ]]
  625. )
  626. # We only need one copy of these across the whole build, since their
  627. # content is only dependent on the version of Doxygen being used. Therefore
  628. # we always put them at the top of the build tree so that they are in a
  629. # predictable location.
  630. set(_doxyfile_in "${CMAKE_BINARY_DIR}/CMakeDoxyfile.in")
  631. set(_doxyfile_defaults "${CMAKE_BINARY_DIR}/CMakeDoxygenDefaults.cmake")
  632. set(_doxyfile_in_contents "")
  633. set(_doxyfile_defaults_contents "")
  634. # Get strings containing a configuration key from the template Doxyfile
  635. # we obtained from this version of Doxygen. Because some options are split
  636. # across multiple lines by ending lines with backslashes, we cannot just
  637. # use file(STRINGS...) with a REGEX. Instead, read lines without a REGEX
  638. # so that file(STRINGS...) handles the trailing backslash as a line
  639. # continuation. It stores multi-lines as lists, so we then have to replace
  640. # the ";" list separator with backslashed newlines again so that we get the
  641. # original content stored back as the value part.
  642. file(STRINGS "${_Doxygen_tpl}" _file_lines)
  643. unset(_Doxygen_tpl_params)
  644. foreach(_line IN LISTS _file_lines)
  645. if(_line MATCHES "([A-Z][A-Z0-9_]+)( *=)(.*)")
  646. set(_key "${CMAKE_MATCH_1}")
  647. set(_eql "${CMAKE_MATCH_2}")
  648. set(_value "${CMAKE_MATCH_3}")
  649. string(REPLACE "\\" "\\\\" _value "${_value}")
  650. string(REPLACE ";" "\\\n" _value "${_value}")
  651. list(APPEND _Doxygen_tpl_params "${_key}${_eql}${_value}")
  652. endif()
  653. endforeach()
  654. # Build up a Doxyfile that provides @configVar@ substitutions for each
  655. # Doxygen config option as well as a separate CMake script which provides
  656. # the default value for each of those options if the project doesn't supply
  657. # them. Each config option will support substitution of a CMake variable
  658. # of the same name except with DOXYGEN_ prepended.
  659. foreach(_Doxygen_param IN LISTS _Doxygen_tpl_params)
  660. if(_Doxygen_param MATCHES "([A-Z][A-Z0-9_]+)( *)=( (.*))?")
  661. # Ok, this is a config key with a value
  662. if(CMAKE_MATCH_COUNT EQUAL 4)
  663. string(APPEND _doxyfile_in_contents
  664. "${CMAKE_MATCH_1}${CMAKE_MATCH_2}= @DOXYGEN_${CMAKE_MATCH_1}@\n")
  665. # Remove the backslashes we had to preserve to handle newlines
  666. string(REPLACE "\\\n" "\n" _value "${CMAKE_MATCH_4}")
  667. string(APPEND _doxyfile_defaults_contents
  668. "if(NOT DEFINED DOXYGEN_${CMAKE_MATCH_1})
  669. set(DOXYGEN_${CMAKE_MATCH_1} ${_value})
  670. endif()
  671. ")
  672. # Ok, this is a config key with empty default value
  673. elseif(CMAKE_MATCH_COUNT EQUAL 2)
  674. string(APPEND _doxyfile_in_contents
  675. "${CMAKE_MATCH_1}${CMAKE_MATCH_2}= @DOXYGEN_${CMAKE_MATCH_1}@\n")
  676. else()
  677. message(AUTHOR_WARNING
  678. "Unexpected line format! Code review required!\nFault line: ${_Doxygen_param}")
  679. endif()
  680. else()
  681. message(AUTHOR_WARNING
  682. "Unexpected line format! Code review required!\nFault line: ${_Doxygen_param}")
  683. endif()
  684. endforeach()
  685. file(WRITE "${_doxyfile_defaults}" "${_Doxygen_do_not_edit_header}"
  686. "${_doxyfile_defaults_contents}")
  687. file(WRITE "${_doxyfile_in}" "${_Doxygen_do_not_edit_header}"
  688. "${_doxyfile_in_contents}")
  689. # Ok, dumped defaults are not needed anymore...
  690. file(REMOVE "${_Doxygen_tpl}")
  691. unset(_Doxygen_param)
  692. unset(_Doxygen_tpl_params)
  693. unset(_Doxygen_do_not_edit_header)
  694. unset(_Doxygen_tpl)
  695. endif()
  696. function(doxygen_quote_value VARIABLE)
  697. # Quote a value of the given variable if:
  698. # - VARIABLE parameter was really given
  699. # - the variable it names is defined and is not present in the list
  700. # specified by DOXYGEN_VERBATIM_VARS (if set)
  701. # - the value of the named variable isn't already quoted
  702. # - the value has spaces
  703. if(VARIABLE AND DEFINED ${VARIABLE} AND
  704. NOT ${VARIABLE} MATCHES "^\".* .*\"$" AND ${VARIABLE} MATCHES " " AND
  705. NOT (DEFINED DOXYGEN_VERBATIM_VARS AND
  706. "${VARIABLE}" IN_LIST DOXYGEN_VERBATIM_VARS))
  707. set(${VARIABLE} "\"${${VARIABLE}}\"" PARENT_SCOPE)
  708. endif()
  709. endfunction()
  710. function(doxygen_list_to_quoted_strings LIST_VARIABLE)
  711. if(LIST_VARIABLE AND DEFINED ${LIST_VARIABLE})
  712. unset(_inputs)
  713. unset(_sep)
  714. unset(_verbatim)
  715. # Have to test if list items should be treated as verbatim here
  716. # because we lose the variable name when we pass just one list item
  717. # to doxygen_quote_value() below
  718. if(DEFINED DOXYGEN_VERBATIM_VARS AND
  719. "${LIST_VARIABLE}" IN_LIST DOXYGEN_VERBATIM_VARS)
  720. set(_verbatim True)
  721. endif()
  722. foreach(_in IN LISTS ${LIST_VARIABLE})
  723. if(NOT _verbatim)
  724. doxygen_quote_value(_in)
  725. endif()
  726. string(APPEND _inputs "${_sep}${_in}")
  727. set(_sep " ")
  728. endforeach()
  729. set(${LIST_VARIABLE} "${_inputs}" PARENT_SCOPE)
  730. endif()
  731. endfunction()
  732. function(doxygen_add_docs targetName)
  733. set(_options ALL USE_STAMP_FILE)
  734. set(_one_value_args WORKING_DIRECTORY COMMENT CONFIG_FILE)
  735. set(_multi_value_args)
  736. cmake_parse_arguments(_args
  737. "${_options}"
  738. "${_one_value_args}"
  739. "${_multi_value_args}"
  740. ${ARGN})
  741. if(NOT _args_COMMENT)
  742. set(_args_COMMENT "Generate API documentation for ${targetName}")
  743. endif()
  744. if(NOT _args_WORKING_DIRECTORY)
  745. set(_args_WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
  746. endif()
  747. if(DEFINED DOXYGEN_INPUT)
  748. message(WARNING
  749. "DOXYGEN_INPUT is set but it will be ignored. Pass the files and directories \
  750. directly to the doxygen_add_docs() command instead.")
  751. endif()
  752. set(DOXYGEN_INPUT ${_args_UNPARSED_ARGUMENTS})
  753. if(NOT TARGET Doxygen::doxygen)
  754. message(FATAL_ERROR "Doxygen was not found, needed by \
  755. doxygen_add_docs() for target ${targetName}")
  756. endif()
  757. # If not already defined, set some relevant defaults based on the
  758. # assumption that the documentation is for the whole project. Details
  759. # specified in the project() command will be used to populate a number of
  760. # these defaults.
  761. if(NOT DEFINED DOXYGEN_PROJECT_NAME)
  762. # The PROJECT_NAME tag is a single word (or a sequence of words
  763. # surrounded by double-quotes, unless you are using Doxywizard) that
  764. # should identify the project for which the documentation is generated.
  765. # This name is used in the title of most generated pages and in a few
  766. # other places. The default value is: My Project.
  767. set(DOXYGEN_PROJECT_NAME ${PROJECT_NAME})
  768. endif()
  769. if(NOT DEFINED DOXYGEN_PROJECT_NUMBER)
  770. # The PROJECT_NUMBER tag can be used to enter a project or revision
  771. # number. This could be handy for archiving the generated documentation
  772. # or if some version control system is used.
  773. set(DOXYGEN_PROJECT_NUMBER ${PROJECT_VERSION})
  774. endif()
  775. if(NOT DEFINED DOXYGEN_PROJECT_BRIEF)
  776. # Using the PROJECT_BRIEF tag one can provide an optional one line
  777. # description for a project that appears at the top of each page and
  778. # should give viewer a quick idea about the purpose of the project.
  779. # Keep the description short.
  780. set(DOXYGEN_PROJECT_BRIEF "${PROJECT_DESCRIPTION}")
  781. endif()
  782. if(NOT DEFINED DOXYGEN_RECURSIVE)
  783. # The RECURSIVE tag can be used to specify whether or not
  784. # subdirectories should be searched for input files as well. CMake
  785. # projects generally evolve to span multiple directories, so it makes
  786. # more sense for this to be on by default. Doxygen's default value
  787. # has this setting turned off, so we override it.
  788. set(DOXYGEN_RECURSIVE YES)
  789. endif()
  790. if(NOT DEFINED DOXYGEN_OUTPUT_DIRECTORY)
  791. # The OUTPUT_DIRECTORY tag is used to specify the (relative or
  792. # absolute) path into which the generated documentation will be
  793. # written. If a relative path is used, Doxygen will interpret it as
  794. # being relative to the location where doxygen was started, but we need
  795. # to run Doxygen in the source tree so that relative input paths work
  796. # intuitively. Therefore, we ensure that the output directory is always
  797. # an absolute path and if the project provided a relative path, we
  798. # treat it as relative to the current BINARY directory so that output
  799. # is not generated inside the source tree.
  800. set(DOXYGEN_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
  801. elseif(NOT IS_ABSOLUTE "${DOXYGEN_OUTPUT_DIRECTORY}")
  802. get_filename_component(DOXYGEN_OUTPUT_DIRECTORY
  803. "${DOXYGEN_OUTPUT_DIRECTORY}"
  804. ABSOLUTE
  805. BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
  806. endif()
  807. if(NOT DEFINED DOXYGEN_HAVE_DOT)
  808. # If you set the HAVE_DOT tag to YES then doxygen will assume the dot
  809. # tool is available from the path. This tool is part of Graphviz (see:
  810. # https://www.graphviz.org/), a graph visualization toolkit from AT&T
  811. # and Lucent Bell Labs. The other options in this section have no
  812. # effect if this option is set to NO.
  813. # Doxygen's default value is: NO.
  814. if(Doxygen_dot_FOUND)
  815. set(DOXYGEN_HAVE_DOT "YES")
  816. else()
  817. set(DOXYGEN_HAVE_DOT "NO")
  818. endif()
  819. endif()
  820. if(NOT DEFINED DOXYGEN_DOT_MULTI_TARGETS)
  821. # Set the DOT_MULTI_TARGETS tag to YES to allow dot to generate
  822. # multiple output files in one run (i.e. multiple -o and -T options on
  823. # the command line). This makes dot run faster, but since only newer
  824. # versions of dot (>1.8.10) support this, Doxygen disables this feature
  825. # by default.
  826. # This tag requires that the tag HAVE_DOT is set to YES.
  827. set(DOXYGEN_DOT_MULTI_TARGETS YES)
  828. endif()
  829. if(NOT DEFINED DOXYGEN_GENERATE_LATEX)
  830. # If the GENERATE_LATEX tag is set to YES, doxygen will generate LaTeX
  831. # output. We only want the HTML output enabled by default, so we turn
  832. # this off if the project hasn't specified it.
  833. set(DOXYGEN_GENERATE_LATEX NO)
  834. endif()
  835. if(NOT DEFINED DOXYGEN_WARN_FORMAT)
  836. if(CMAKE_VS_MSBUILD_COMMAND OR CMAKE_VS_DEVENV_COMMAND)
  837. # The WARN_FORMAT tag determines the format of the warning messages
  838. # that doxygen can produce. The string should contain the $file,
  839. # $line and $text tags, which will be replaced by the file and line
  840. # number from which the warning originated and the warning text.
  841. # Optionally, the format may contain $version, which will be
  842. # replaced by the version of the file (if it could be obtained via
  843. # FILE_VERSION_FILTER).
  844. # Doxygen's default value is: $file:$line: $text
  845. set(DOXYGEN_WARN_FORMAT "$file($line) : $text ")
  846. endif()
  847. endif()
  848. if(DEFINED DOXYGEN_WARN_LOGFILE AND NOT IS_ABSOLUTE "${DOXYGEN_WARN_LOGFILE}")
  849. # The WARN_LOGFILE tag can be used to specify a file to which warning and error
  850. # messages should be written. If left blank the output is written to standard
  851. # error (stderr).
  852. get_filename_component(DOXYGEN_WARN_LOGFILE
  853. "${DOXYGEN_WARN_LOGFILE}"
  854. ABSOLUTE
  855. BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
  856. endif()
  857. # Any files from the INPUT that match any of the EXCLUDE_PATTERNS will be
  858. # excluded from the set of input files. We provide some additional patterns
  859. # to prevent commonly unwanted things from CMake builds being pulled in.
  860. #
  861. # Note that the wildcards are matched against the file with absolute path,
  862. # so to exclude all test directories for example use the pattern */test/*
  863. list(
  864. APPEND
  865. DOXYGEN_EXCLUDE_PATTERNS
  866. "*/.git/*"
  867. "*/.svn/*"
  868. "*/.hg/*"
  869. "*/CMakeFiles/*"
  870. "*/_CPack_Packages/*"
  871. "DartConfiguration.tcl"
  872. "CMakeLists.txt"
  873. "CMakeCache.txt"
  874. )
  875. # Now bring in Doxygen's defaults for those things the project has not
  876. # already set and we have not provided above
  877. include("${CMAKE_BINARY_DIR}/CMakeDoxygenDefaults.cmake" OPTIONAL)
  878. # Cleanup built HTMLs on "make clean"
  879. # TODO Any other dirs?
  880. if(DOXYGEN_GENERATE_HTML)
  881. if(IS_ABSOLUTE "${DOXYGEN_HTML_OUTPUT}")
  882. set(_args_clean_html_dir "${DOXYGEN_HTML_OUTPUT}")
  883. else()
  884. set(_args_clean_html_dir
  885. "${DOXYGEN_OUTPUT_DIRECTORY}/${DOXYGEN_HTML_OUTPUT}")
  886. endif()
  887. set_property(DIRECTORY APPEND PROPERTY
  888. ADDITIONAL_CLEAN_FILES "${_args_clean_html_dir}")
  889. endif()
  890. # Build up a list of files we can identify from the inputs so we can list
  891. # them as DEPENDS and SOURCES in the custom command/target (the latter
  892. # makes them display in IDEs). This must be done before we transform the
  893. # various DOXYGEN_... variables below because we need to process
  894. # DOXYGEN_INPUT as a list first.
  895. unset(_sources)
  896. foreach(_item IN LISTS DOXYGEN_INPUT)
  897. get_filename_component(_abs_item "${_item}" ABSOLUTE
  898. BASE_DIR "${_args_WORKING_DIRECTORY}")
  899. get_source_file_property(_isGenerated "${_abs_item}" GENERATED)
  900. if(_isGenerated OR
  901. (EXISTS "${_abs_item}" AND
  902. NOT IS_DIRECTORY "${_abs_item}" AND
  903. NOT IS_SYMLINK "${_abs_item}"))
  904. list(APPEND _sources "${_abs_item}")
  905. elseif(_args_USE_STAMP_FILE)
  906. message(FATAL_ERROR "Source does not exist or is not a file:\n"
  907. " ${_abs_item}\n"
  908. "Only existing files may be specified when the "
  909. "USE_STAMP_FILE option is given.")
  910. endif()
  911. endforeach()
  912. # Transform known list type options into space separated strings.
  913. set(_doxygen_list_options
  914. ABBREVIATE_BRIEF
  915. ALIASES
  916. CITE_BIB_FILES
  917. DIAFILE_DIRS
  918. DOTFILE_DIRS
  919. DOT_FONTPATH
  920. ENABLED_SECTIONS
  921. EXAMPLE_PATH
  922. EXAMPLE_PATTERNS
  923. EXCLUDE
  924. EXCLUDE_PATTERNS
  925. EXCLUDE_SYMBOLS
  926. EXPAND_AS_DEFINED
  927. EXTENSION_MAPPING
  928. EXTRA_PACKAGES
  929. EXTRA_SEARCH_MAPPINGS
  930. FILE_PATTERNS
  931. FILTER_PATTERNS
  932. FILTER_SOURCE_PATTERNS
  933. HTML_EXTRA_FILES
  934. HTML_EXTRA_STYLESHEET
  935. IGNORE_PREFIX
  936. IMAGE_PATH
  937. INCLUDE_FILE_PATTERNS
  938. INCLUDE_PATH
  939. INPUT
  940. LATEX_EXTRA_FILES
  941. LATEX_EXTRA_STYLESHEET
  942. MATHJAX_EXTENSIONS
  943. MSCFILE_DIRS
  944. PLANTUML_INCLUDE_PATH
  945. PREDEFINED
  946. QHP_CUST_FILTER_ATTRS
  947. QHP_SECT_FILTER_ATTRS
  948. STRIP_FROM_INC_PATH
  949. STRIP_FROM_PATH
  950. TAGFILES
  951. TCL_SUBST
  952. )
  953. foreach(_item IN LISTS _doxygen_list_options)
  954. doxygen_list_to_quoted_strings(DOXYGEN_${_item})
  955. endforeach()
  956. # Transform known single value variables which may contain spaces, such as
  957. # paths or description strings.
  958. set(_doxygen_quoted_options
  959. CHM_FILE
  960. DIA_PATH
  961. DOCBOOK_OUTPUT
  962. DOCSET_FEEDNAME
  963. DOCSET_PUBLISHER_NAME
  964. DOT_FONTNAME
  965. DOT_PATH
  966. EXTERNAL_SEARCH_ID
  967. FILE_VERSION_FILTER
  968. GENERATE_TAGFILE
  969. HHC_LOCATION
  970. HTML_FOOTER
  971. HTML_HEADER
  972. HTML_OUTPUT
  973. HTML_STYLESHEET
  974. INPUT_FILTER
  975. LATEX_FOOTER
  976. LATEX_HEADER
  977. LATEX_OUTPUT
  978. LAYOUT_FILE
  979. MAN_OUTPUT
  980. MAN_SUBDIR
  981. MATHJAX_CODEFILE
  982. MSCGEN_PATH
  983. OUTPUT_DIRECTORY
  984. PERL_PATH
  985. PLANTUML_JAR_PATH
  986. PROJECT_BRIEF
  987. PROJECT_LOGO
  988. PROJECT_NAME
  989. QCH_FILE
  990. QHG_LOCATION
  991. QHP_CUST_FILTER_NAME
  992. QHP_VIRTUAL_FOLDER
  993. RTF_EXTENSIONS_FILE
  994. RTF_OUTPUT
  995. RTF_STYLESHEET_FILE
  996. SEARCHDATA_FILE
  997. USE_MDFILE_AS_MAINPAGE
  998. WARN_FORMAT
  999. WARN_LOGFILE
  1000. XML_OUTPUT
  1001. )
  1002. # Store the unmodified value of DOXYGEN_OUTPUT_DIRECTORY prior to invoking
  1003. # doxygen_quote_value() below. This will mutate the string specifically for
  1004. # consumption by Doxygen's config file, which we do not want when we use it
  1005. # later in the custom target's commands.
  1006. set( _original_doxygen_output_dir ${DOXYGEN_OUTPUT_DIRECTORY} )
  1007. foreach(_item IN LISTS _doxygen_quoted_options)
  1008. doxygen_quote_value(DOXYGEN_${_item})
  1009. endforeach()
  1010. # Prepare doxygen configuration file
  1011. set(_doxyfile_template "${CMAKE_BINARY_DIR}/CMakeDoxyfile.in")
  1012. if(_args_CONFIG_FILE)
  1013. if(NOT EXISTS "${_args_CONFIG_FILE}")
  1014. message(FATAL_ERROR "Option CONFIG_FILE specifies file:\n ${_args_CONFIG_FILE}\nbut it does not exist.")
  1015. endif()
  1016. set(_target_doxyfile "${_args_CONFIG_FILE}")
  1017. else()
  1018. set(_target_doxyfile "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.${targetName}")
  1019. configure_file("${_doxyfile_template}" "${_target_doxyfile}")
  1020. endif()
  1021. unset(_all)
  1022. if(${_args_ALL})
  1023. set(_all ALL)
  1024. endif()
  1025. # Only create the stamp file if asked to. If we don't create it,
  1026. # the target will always be considered out-of-date.
  1027. if(_args_USE_STAMP_FILE)
  1028. set(__stamp_file "${CMAKE_CURRENT_BINARY_DIR}/${targetName}.stamp")
  1029. add_custom_command(
  1030. VERBATIM
  1031. OUTPUT ${__stamp_file}
  1032. COMMAND ${CMAKE_COMMAND} -E make_directory ${_original_doxygen_output_dir}
  1033. COMMAND "${DOXYGEN_EXECUTABLE}" "${_target_doxyfile}"
  1034. COMMAND ${CMAKE_COMMAND} -E touch ${__stamp_file}
  1035. WORKING_DIRECTORY "${_args_WORKING_DIRECTORY}"
  1036. DEPENDS "${_target_doxyfile}" ${_sources}
  1037. COMMENT "${_args_COMMENT}"
  1038. )
  1039. add_custom_target(${targetName} ${_all}
  1040. DEPENDS ${__stamp_file}
  1041. SOURCES ${_sources}
  1042. )
  1043. unset(__stamp_file)
  1044. else()
  1045. add_custom_target( ${targetName} ${_all} VERBATIM
  1046. COMMAND ${CMAKE_COMMAND} -E make_directory ${_original_doxygen_output_dir}
  1047. COMMAND "${DOXYGEN_EXECUTABLE}" "${_target_doxyfile}"
  1048. WORKING_DIRECTORY "${_args_WORKING_DIRECTORY}"
  1049. DEPENDS "${_target_doxyfile}" ${_sources}
  1050. COMMENT "${_args_COMMENT}"
  1051. SOURCES ${_sources}
  1052. )
  1053. endif()
  1054. endfunction()