Skip to content

Commit 3cdb5e8

Browse files
committed
Added CMake logic to build ROBODoc documentation
1 parent 9d264a2 commit 3cdb5e8

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

CMakeLists.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,40 @@ set_target_properties ( ${LIB_NAME}
102102
SOVERSION ${VERSION_MAJOR}.${VERSION_MINOR}
103103
VERSION ${VERSION} )
104104

105+
#-------------------------------------
106+
# Build the documentation with ROBODoc
107+
#-------------------------------------
108+
set ( ROBODOC_SKIP_DOC_GEN FALSE CACHE BOOL
109+
"Disable building the API documentation with ROBODoc" )
110+
if ( NOT ROBODOC_SKIP_DOC_GEN )
111+
find_program ( ROBODOC robodoc )
112+
if ( ROBODOC ) # Found
113+
set ( ROBODOC_OPTIONS --tabsize 4 --index --toc --sections --syntaxcolors --source_line_numbers
114+
CACHE STRING "Options passed to robodoc to control building the documentation" )
115+
set ( DOC_DIR "${CMAKE_BINARY_DIR}/doc" )
116+
set ( REQUIRED_ROBODOC_OPTIONS
117+
--src "${CMAKE_SOURCE_DIR}/src" --doc "${DOC_DIR}"
118+
--multidoc --html --ignore_case_when_linking
119+
--documenttitle "${CMAKE_PROJECT_NAME}" )
120+
set ( ROBODOC_OUPUTS json_example_f90.html masterindex.html robo_functions.html robo_sourcefiles.html
121+
toc_index.html json_module_f90.html robo_classes.html robo_modules.html robodoc.css )
122+
foreach ( ARG ${ROBODOC_OUPUTS} )
123+
set ( ROBO_OUTPUTS "${DOC_DIR}/${ARG}" )
124+
endforeach ( ARG ${ROBODOC_OUPUTS} )
125+
add_custom_command ( OUTPUT ${ROBO_OUTPUTS}
126+
COMMAND "${CMAKE_COMMAND}" -E make_directory "${DOC_DIR}" # Ensure DOC_DIR exists at build time
127+
COMMAND "${ROBODOC}" ${REQUIRED_ROBODOC_OPTIONS} ${ROBODOC_OPTIONS}
128+
DEPENDS "${CMAKE_SOURCE_DIR}/${JF_LIB_SRCS}"
129+
COMMENT "Building HTML documentation for ${CMAKE_PROJECT_NAME} using ROBODoc" )
130+
add_custom_target ( documentation ALL
131+
DEPENDS ${ROBO_OUTPUTS} )
132+
set_directory_properties ( PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES doc )
133+
else ( ROBODOC ) # Not found
134+
message ( WARNING
135+
"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." )
136+
endif ( ROBODOC )
137+
endif ( NOT ROBODOC_SKIP_DOC_GEN )
138+
105139
#---------------------------------------------------------------------
106140
# Add some tests to ensure that the software is performing as expected
107141
#---------------------------------------------------------------------

0 commit comments

Comments
 (0)