@@ -106,6 +106,14 @@ cmake_dependent_option(
106106 OFF
107107)
108108
109+ cmake_dependent_option (
110+ ITK_DOXYGEN_WARNINGS_ONLY
111+ "Doxygen emits warnings as errors without generating output formats or implicit graphs"
112+ OFF
113+ "ITK_BUILD_DOCUMENTATION"
114+ OFF
115+ )
116+
109117mark_as_advanced (
110118 ITK_DOXYGEN_HTML
111119 ITK_DOXYGEN_DOCSET
@@ -116,6 +124,7 @@ mark_as_advanced(
116124 ITK_DOXYGEN_RTF
117125 ITK_DOXYGEN_XML
118126 ITK_DOXYGEN_SERVER_BASED_SEARCH
127+ ITK_DOXYGEN_WARNINGS_ONLY
119128)
120129
121130# -------------------------------------------------------------
@@ -166,6 +175,11 @@ if(ITK_BUILD_DOCUMENTATION)
166175 "${ITK_SOURCE_DIR } /Examples"
167176 "${ITK_SOURCE_DIR } /Utilities/Doxygen/GenerateExamplesDox.cmake"
168177 )
178+ add_custom_target (
179+ ITKDoxygenExamplesDox
180+ DEPENDS
181+ "${ITK_BINARY_DIR } /Documentation/Doxygen/Examples.dox"
182+ )
169183
170184 set (
171185 ITK_DOXYGEN_INPUT
@@ -181,6 +195,40 @@ if(ITK_BUILD_DOCUMENTATION)
181195 # The DoxygenConfig.cmake is a replacement for configuring a doxygen.config.in file
182196 # https://cmake.org/cmake/help/v3.16/module/FindDoxygen.html
183197 include (${CMAKE_CURRENT_LIST_DIR } /DoxygenConfig.cmake )
198+ if (ITK_DOXYGEN_WARNINGS_ONLY)
199+ foreach (
200+ _format
201+ ITEMS
202+ HTML
203+ DOCSET
204+ CHM
205+ QHP
206+ ECLIPSEHELP
207+ LATEX
208+ RTF
209+ XML
210+ )
211+ set (DOXYGEN_GENERATE_${_format} "NO" )
212+ endforeach ()
213+ # Explicit \dot commands still render; only the implicit graph classes are disabled.
214+ foreach (
215+ _graph
216+ ITEMS
217+ CLASS_GRAPH
218+ COLLABORATION_GRAPH
219+ INCLUDE_GRAPH
220+ INCLUDED_BY_GRAPH
221+ CALL_GRAPH
222+ CALLER_GRAPH
223+ GRAPHICAL_HIERARCHY
224+ DIRECTORY_GRAPH
225+ )
226+ set (DOXYGEN_${_graph} "NO" )
227+ endforeach ()
228+ set (DOXYGEN_WARN_AS_ERROR "FAIL_ON_WARNINGS" )
229+ set (DOXYGEN_WARN_LOGFILE "${ITK_BINARY_DIR } /doxygen-warnings.log" )
230+ # GENERATE_TAGFILE stays: doxygen requires at least one output and the tag file is the cheapest.
231+ endif ()
184232 doxygen_add_docs (
185233 Documentation
186234 ${ITK_DOXYGEN_INPUT}
@@ -190,6 +238,7 @@ if(ITK_BUILD_DOCUMENTATION)
190238 COMMENT "-- Building ITK Doxygen."
191239 )
192240 unset (ITK_DOXYGEN_INPUT)
241+ add_dependencies (Documentation ITKDoxygenExamplesDox )
193242
194243 # add_custom_target(Documentation ALL
195244 # COMMAND ${DOXYGEN_EXECUTABLE} ${ITK_BINARY_DIR}/Utilities/Doxygen/doxygen.config
@@ -202,14 +251,16 @@ if(ITK_BUILD_DOCUMENTATION)
202251 # Somehow the logo image is not copied into the html folder.
203252 # Here we ensure that the logo image ends up in the right directory
204253 # where html pages could find it.
205- add_custom_command (
206- TARGET Documentation
207- POST_BUILD
208- COMMAND
209- ${CMAKE_COMMAND } -E copy
210- ${ITK_SOURCE_DIR } /Documentation/Art/itkLogoSmall.png # logo
211- ${ITK_DOXYGEN_OUTPUT_DIR} /html # output doxygen directory
212- )
254+ if (DOXYGEN_GENERATE_HTML STREQUAL "YES" )
255+ add_custom_command (
256+ TARGET Documentation
257+ POST_BUILD
258+ COMMAND
259+ ${CMAKE_COMMAND } -E copy
260+ ${ITK_SOURCE_DIR } /Documentation/Art/itkLogoSmall.png # logo
261+ ${ITK_DOXYGEN_OUTPUT_DIR} /html # output doxygen directory
262+ )
263+ endif ()
213264
214265 message (
215266 STATUS
0 commit comments