@@ -15,23 +15,38 @@ include(CMakeParseArguments)
1515# the Sphinx documentation for an individual example. The Sphinx target will be
1616# called ${example_name}Doc.
1717macro (add_example example_name )
18- if (BUILD_DOCUMENTATION)
19- if (SPHINX_HTML_OUTPUT)
20- add_custom_target (${example_name} DownloadableArchive
21- COMMAND ${PYTHON_EXECUTABLE} ${ITKSphinxExamples_SOURCE_DIR} /Utilities/CreateDownloadableArchive.py
22- ${example_name} ${SPHINX_DESTINATION}
23- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
24- COMMENT "Creating downloadable archive for ${example_name} "
25- DEPENDS copy_sources
26- )
27- add_dependencies (CreateDownloadableArchives ${example_name} DownloadableArchive )
28- endif ()
29- endif ()
30-
3118 # Process the example's CMakeLists.txt
3219 add_subdirectory (${example_name} )
3320endmacro ()
3421
22+ # Macro for adding module archives
23+ macro (add_module_archives _module_name )
24+ file (GLOB
25+ ${_module_name} _EXAMPLE_DIRS
26+ CONFIGURE_DEPENDS
27+ ${CMAKE_CURRENT_SOURCE_DIR} /${_module_name}/*/
28+ )
29+
30+ if (BUILD_DOCUMENTATION AND SPHINX_HTML_OUTPUT)
31+ foreach (_example_path ${${_module_name} _EXAMPLE_DIRS})
32+ if (IS_DIRECTORY ${_example_path} )
33+ get_filename_component (_example_name ${_example_path} NAME )
34+ get_filename_component (_example_parent_path ${_example_path} DIRECTORY )
35+ get_filename_component (_example_parent_name ${_example_parent_path} NAME )
36+ set (_archive_target ${_example_parent_name} _${_example_name} _DownloadableArchive)
37+ add_custom_target (${_archive_target}
38+ COMMAND ${PYTHON_EXECUTABLE} ${ITKSphinxExamples_SOURCE_DIR} /Utilities/CreateDownloadableArchive.py
39+ ${_example_name} ${SPHINX_DESTINATION}
40+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} /${_example_parent_name}
41+ COMMENT "Creating downloadable archive for ${_example_name} "
42+ DEPENDS copy_sources
43+ )
44+ add_dependencies (CreateDownloadableArchives ${_archive_target} )
45+ endif ()
46+ endforeach ()
47+ endif ()
48+ endmacro ()
49+
3550
3651# Macro if the corresponding module is enabled when ITK was built
3752# Pass in the module directory path. Also pass the module name as the second
@@ -48,6 +63,21 @@ macro(add_subdirectory_if_module_enabled _dir)
4863 endif ()
4964endmacro ()
5065
66+ macro (add_subdirectories_if_module_enabled _dirs_to_ignore )
67+ file (GLOB
68+ _current_subdirectories
69+ CONFIGURE_DEPENDS
70+ ${CMAKE_CURRENT_SOURCE_DIR} /*/
71+ )
72+ message (STATUS "Got subdirectories ${_current_subdirectories} " )
73+ foreach (_subdir ${_current_subdirectories} )
74+ get_filename_component (_subdir_name ${_subdir} NAME )
75+ if (${_subdir_name} NOT IN ${_dirs_to_ignore} )
76+ add_subdirectory_if_module_enabled (${_subdir_name} )
77+ endif ()
78+ endforeach ()
79+ endmacro ()
80+
5181# Creates a test that compares the output image of an example to its baseline
5282# image.
5383#
0 commit comments