@@ -138,41 +138,45 @@ set_target_properties ( ${LIB_NAME}
138
138
Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR} )
139
139
140
140
#-------------------------------------
141
- # Build the documentation with ROBODoc
141
+ # Build the documentation with FORD
142
142
#-------------------------------------
143
143
set ( SKIP_DOC_GEN FALSE CACHE BOOL
144
- "Disable building the API documentation with ROBODoc " )
144
+ "Disable building the API documentation with FORD " )
145
145
if ( NOT SKIP_DOC_GEN )
146
- find_program ( ROBODOC robodoc )
147
- if ( ROBODOC ) # Found
148
- set ( ROBODOC_OPTIONS --rc ${CMAKE_SOURCE_DIR} /robodoc.rc
149
- CACHE STRING "Options passed to robodoc to control building the documentation" )
150
- set ( DOC_DIR "${CMAKE_BINARY_DIR} /documentation" )
151
- set ( REQUIRED_ROBODOC_OPTIONS
152
- --src "${CMAKE_SOURCE_DIR} /src" --doc "${DOC_DIR} "
153
- --documenttitle "${CMAKE_PROJECT_NAME} " )
154
- # Dynamically generate the ROBODoc outputs list
155
- message ( STATUS "Dynamically computing ROBODoc output information..." )
156
- execute_process ( COMMAND ${CMAKE_COMMAND} -E remove_directory ${DOC_DIR}
157
- COMMAND ${CMAKE_COMMAND} -E make_directory ${DOC_DIR}
158
- COMMAND "${ROBODOC} " ${REQUIRED_ROBODOC_OPTIONS} ${ROBODOC_OPTIONS} )
159
- file ( GLOB_RECURSE ROBODOC_OUTPUTS
160
- "${DOC_DIR} /*" )
161
- execute_process ( COMMAND ${CMAKE_COMMAND} -E remove_directory ${DOC_DIR} )
162
- message ( STATUS "Done dynamically computing ROBODoc outputs." )
146
+ find_program ( FORD ford )
147
+ if ( FORD ) # Found
148
+ set ( DOC_DIR "${CMAKE_BINARY_DIR} /doc" )
149
+ set ( FORD_PROJECT_FILE "${CMAKE_SOURCE_DIR} /json-fortran.md" )
150
+ # Dynamically generate the FORD outputs list
151
+ message ( STATUS "Dynamically computing FORD output information..." )
152
+ if ( NOT (DEFINED FORD_OUTPUTS_CACHED ) )
153
+ message ( STATUS "Running FORD to dynamically compute documentation outputs, this could take a while..." )
154
+ execute_process ( COMMAND ${CMAKE_COMMAND} -E remove_directory ${DOC_DIR}
155
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${DOC_DIR}
156
+ COMMAND "${FORD} " -d "${CMAKE_SOURCE_DIR} /src" -o "${DOC_DIR} " "${FORD_PROJECT_FILE} " OUTPUT_QUIET )
157
+ endif ()
158
+ file ( GLOB_RECURSE FORD_OUTPUTS
159
+ "${DOC_DIR} /*.html" )
160
+ file ( GLOB_RECURSE FORD_CLEAN_OUTPUTS
161
+ "${DOC_DIR} /*.*" )
162
+ if ( (DEFINED FORD_OUTPUTS ) AND ( NOT ( "${FORD_OUTPUTS} " STREQUAL "" ) ) )
163
+ set ( FORD_OUTPUTS_CACHED "${FORD_OUTPUTS} "
164
+ CACHE INTERNAL "internal variable to attempt to prevent rebuilding FORD docs" FORCE )
165
+ endif ()
166
+ message ( STATUS "Done dynamically computing FORD outputs." )
163
167
164
168
foreach ( SRC_FILE ${JF_LIB_SRCS} ${JF_TEST_SRCS} )
165
- list ( APPEND ROBO_DEPENDS "${SRC_FILE} " )
169
+ list ( APPEND FORD_DEPENDS "${SRC_FILE} " )
166
170
endforeach ( SRC_FILE )
167
- add_custom_command ( OUTPUT ${ROBODOC_OUTPUTS }
168
- COMMAND "${CMAKE_COMMAND } " -E make_directory "${DOC_DIR} " # Ensure DOC_DIR exists at build time
169
- COMMAND "${ROBODOC} " ${REQUIRED_ROBODOC_OPTIONS} ${ROBODOC_OPTIONS}
170
- DEPENDS ${ROBO_DEPENDS }
171
- COMMENT "Building HTML documentation for ${CMAKE_PROJECT_NAME} using ROBODoc " )
171
+ add_custom_command ( OUTPUT ${FORD_OUTPUTS_CACHED }
172
+ COMMAND "${FORD } " -d "${CMAKE_SOURCE_DIR} /src" -o " ${ DOC_DIR} " " ${FORD_PROJECT_FILE} "
173
+ MAIN_DEPENDENCY "${FORD_PROJECT_FILE} "
174
+ DEPENDS ${FORD_DEPENDS }
175
+ COMMENT "Building HTML documentation for ${CMAKE_PROJECT_NAME} using FORD " )
172
176
add_custom_target ( documentation ALL
173
- DEPENDS ${ROBODOC_OUTPUTS } )
177
+ DEPENDS ${FORD_OUTPUTS } )
174
178
set ( INSTALL_API_DOCUMENTATION TRUE
175
- CACHE BOOL "Install ROBODoc generated documentation?" )
179
+ CACHE BOOL "Install FORD generated documentation?" )
176
180
if ( INSTALL_API_DOCUMENTATION )
177
181
if ( USE_GNU_INSTALL_CONVENTION )
178
182
install ( DIRECTORY "${DOC_DIR} /" DESTINATION "${CMAKE_INSTALL_DOCDIR} " )
@@ -182,7 +186,7 @@ if ( NOT SKIP_DOC_GEN )
182
186
endif ()
183
187
else () # Not found
184
188
message ( WARNING
185
- "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_DOC_GEN to TRUE." )
189
+ "FORD not found! Please set the CMake cache variable FORD to point to the installed FORD executable , and reconfigure or disable building the documentation. FORD can be installed from PYPI with `sudo pip install FORD` or from <https ://github.com/cmacmackin/ford> If you do not wish to install FORD and build the json-fortran documentation, then please set the CMake cache variable SKIP_DOC_GEN to TRUE." )
186
190
endif ()
187
191
endif ()
188
192
@@ -209,7 +213,7 @@ if ( ENABLE_TESTS )
209
213
set ( DATA_DIR "${CMAKE_BINARY_DIR} /files" )
210
214
211
215
set_directory_properties ( PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
212
- "${DATA_DIR} /test2.json;${DATA_DIR} /test4.json" )
216
+ "${DATA_DIR} /test2.json;${DATA_DIR} /test4.json; ${FORD_CLEAN_OUTPUTS} " )
213
217
214
218
# Validate input
215
219
if ( JSONLINT )
@@ -222,7 +226,7 @@ if ( ENABLE_TESTS )
222
226
get_filename_component ( TESTNAME "${VALID_JSON} " NAME )
223
227
add_test ( NAME validate-${TESTNAME}
224
228
WORKING_DIRECTORY "${DATA_DIR} /inputs"
225
- COMMAND ${JSONLINT} "${VALID_JSON} " )
229
+ COMMAND ${JSONLINT} "--allow=nonescape-characters" " ${VALID_JSON} " )
226
230
endforeach ()
227
231
228
232
foreach ( INVALID ${INVALID_JSON} )
@@ -267,7 +271,7 @@ if ( ENABLE_TESTS )
267
271
get_filename_component ( TESTNAME ${JSON_FILE} NAME )
268
272
add_test ( NAME validate-output-${TESTNAME}
269
273
WORKING_DIRECTORY "${DATA_DIR} "
270
- COMMAND ${JSONLINT} ${TESTNAME} )
274
+ COMMAND ${JSONLINT} "--allow=nonescape-characters" ${TESTNAME} )
271
275
set_property ( TEST validate-output-${TESTNAME}
272
276
APPEND
273
277
PROPERTY
0 commit comments