@@ -162,31 +162,50 @@ if(ITK_BUILD_DOCUMENTATION)
162162
163163 find_package (LATEX )
164164
165+ file (
166+ GLOB_RECURSE EXAMPLES_LIST
167+ CONFIGURE_DEPENDS
168+ "${ITK_SOURCE_DIR } /Examples/*.cxx"
169+ "${ITK_SOURCE_DIR } /Examples/*.py"
170+ "${ITK_SOURCE_DIR } /Examples/*.java"
171+ )
172+ set (ITK_EXAMPLES ${ITK_BINARY_DIR } /Documentation/Doxygen/Examples.dox)
173+
174+ # Removing an example changes only EXAMPLES_LIST, which cannot make
175+ # Examples.dox out of date; depend on a stamp holding the list itself so a
176+ # deletion is seen. file(CONFIGURE) rewrites only when the content differs.
177+ set (
178+ ITK_EXAMPLES_LIST_STAMP
179+ ${ITK_BINARY_DIR } /Documentation/Doxygen/ExamplesList.txt
180+ )
181+ string (REPLACE ";" "\n " ITK_EXAMPLES_LIST_CONTENT "${EXAMPLES_LIST} " )
182+ file (
183+ CONFIGURE
184+ OUTPUT ${ITK_EXAMPLES_LIST_STAMP}
185+ CONTENT "${ITK_EXAMPLES_LIST_CONTENT} \n "
186+ )
187+
165188 # Custom command to generate a examples page which include all ITK examples
166189 add_custom_command (
167190 OUTPUT
168- " ${ ITK_BINARY_DIR } /Documentation/Doxygen/Examples.dox"
191+ ${ITK_EXAMPLES}
169192 COMMAND
170193 ${CMAKE_COMMAND } -D "PROJECT_SOURCE_DIR:PATH=${ITK_SOURCE_DIR } " -D
171- "OUTPUT_FILE:PATH=${ITK_BINARY_DIR } /Documentation/Doxygen/Examples.dox " -P
194+ "OUTPUT_FILE:PATH=${ITK_EXAMPLES} " -P
172195 "${ITK_SOURCE_DIR } /Utilities/Doxygen/GenerateExamplesDox.cmake"
173- WORKING_DIRECTORY "${ITK_SOURCE_DIR } /Examples"
174196 DEPENDS
175- "${ITK_SOURCE_DIR } /Examples"
197+ ${EXAMPLES_LIST}
198+ ${ITK_EXAMPLES_LIST_STAMP}
176199 "${ITK_SOURCE_DIR } /Utilities/Doxygen/GenerateExamplesDox.cmake"
177200 )
178- add_custom_target (
179- ITKDoxygenExamplesDox
180- DEPENDS
181- "${ITK_BINARY_DIR } /Documentation/Doxygen/Examples.dox"
182- )
201+ add_custom_target (ITKDoxygenExamplesDox ALL DEPENDS ${ITK_EXAMPLES} )
183202
184203 set (
185204 ITK_DOXYGEN_INPUT
186205 ${DOXYGEN_INCLUDE_DIRS}
187206 ${ITK_SOURCE_DIR } /Documentation/Doxygen
188207 ${ITK_BINARY_DIR } /Documentation/Doxygen
189- ${ITK_BINARY_DIR } /Documentation/Doxygen/Examples.dox
208+ ${ITK_EXAMPLES}
190209 ${ITK_BINARY_DIR } /Utilities/Doxygen/Modules
191210 ${ITK_DOXYGEN_INPUT}
192211 )
0 commit comments