FindDoxygen.cmake 42 KB

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