Skip to content

Commit bb7a8c6

Browse files
committed
BUGFIX: CMake documentation generation bugfix
- Products of the custom command to generate documentation were not properly listed - Now, make clean will clean the documentation directory without use of `set_directory_properties()` - ROBODoc outputs dynamically computed at CMake configuration time. Fixes #17 - Change in ROBODoc Headers or new source files will no longers require manual update of the outputs
1 parent 963d112 commit bb7a8c6

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

CMakeLists.txt

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,23 @@ if ( NOT ROBODOC_SKIP_DOC_GEN )
119119
--src "${CMAKE_SOURCE_DIR}/src" --doc "${DOC_DIR}"
120120
--multidoc --html --ignore_case_when_linking
121121
--documenttitle "${CMAKE_PROJECT_NAME}" )
122-
set ( ROBODOC_OUPUTS json_example_f90.html masterindex.html robo_functions.html robo_sourcefiles.html
123-
toc_index.html json_module_f90.html robo_classes.html robo_modules.html robodoc.css )
124-
foreach ( ARG ${ROBODOC_OUPUTS} )
125-
set ( ROBO_OUTPUTS "${DOC_DIR}/${ARG}" )
126-
endforeach ( ARG ${ROBODOC_OUPUTS} )
127-
add_custom_command ( OUTPUT ${ROBO_OUTPUTS}
122+
# Dynamically generate the ROBODoc outputs list
123+
message ( STATUS "Dynamically computing ROBODoc output information..." )
124+
execute_process ( COMMAND ${CMAKE_COMMAND} -E remove_directory ${DOC_DIR}
125+
COMMAND ${CMAKE_COMMAND} -E make_directory ${DOC_DIR}
126+
COMMAND "${ROBODOC}" ${REQUIRED_ROBODOC_OPTIONS} ${ROBODOC_OPTIONS} )
127+
file ( GLOB_RECURSE ROBODOC_OUTPUTS
128+
"${DOC_DIR}/*" )
129+
execute_process ( COMMAND ${CMAKE_COMMAND} -E remove_directory ${DOC_DIR} )
130+
message ( STATUS "Done dynamically computing ROBODoc outputs." )
131+
132+
add_custom_command ( OUTPUT ${ROBODOC_OUTPUTS}
128133
COMMAND "${CMAKE_COMMAND}" -E make_directory "${DOC_DIR}" # Ensure DOC_DIR exists at build time
129134
COMMAND "${ROBODOC}" ${REQUIRED_ROBODOC_OPTIONS} ${ROBODOC_OPTIONS}
130135
DEPENDS "${CMAKE_SOURCE_DIR}/${JF_LIB_SRCS}"
131136
COMMENT "Building HTML documentation for ${CMAKE_PROJECT_NAME} using ROBODoc" )
132137
add_custom_target ( documentation ALL
133-
DEPENDS ${ROBO_OUTPUTS} )
138+
DEPENDS ${ROBODOC_OUTPUTS} )
134139
else ( ROBODOC ) # Not found
135140
message ( WARNING
136141
"ROBODoc not found! Please set the CMake cache variable ROBODOC to point to the installed ROBODoc binary, and reconfigure or disable building the documentation. ROBODoc can be installed from: http://www.xs4all.nl/~rfsber/Robo/ If you do not wish to install ROBODoc and build the json-fortran documentation, then please set the CMake cache variable SKIP_DOCUMENTATION_GENERATION to FALSE." )

0 commit comments

Comments
 (0)