Skip to content

Commit e501011

Browse files
committed
Update CMake build script to use FORD instead of ROBODoc
- Outputs still dynamically computed at configure time - Outputs not deleted after configure since FORD build is slower - FORD outputs cached so that running CMake again doesn't recompute them unless they need to be. - Small issue with some of the modification time of FORD files, see https://github.com/cmacmackin/ford/issues/55
1 parent d6802f8 commit e501011

File tree

2 files changed

+37
-33
lines changed

2 files changed

+37
-33
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ env:
1212
# CMake build with unit tests, no documentation, with coverage analysis
1313
# No unicode so that coverage combined with the build script will cover unicode
1414
# and non-unicode code paths
15-
- BUILD_SCRIPT="mkdir cmake-build && cd cmake-build && cmake -DSKIP_DOC_GEN:BOOL=TRUE -DCMAKE_BUILD_TYPE=COVERAGE .. && make -j 4 check"
15+
- BUILD_SCRIPT="mkdir cmake-build && cd cmake-build && cmake -DCMAKE_BUILD_TYPE=COVERAGE .. && make -j 4 check"
1616
SPECIFIC_DEPENDS="cmake nodejs"
1717
JLINT="yes"
18-
DOCS="no"
18+
DOCS="yes"
1919
FoBiS="no"
2020
CODE_COVERAGE="yes"
2121

CMakeLists.txt

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -138,41 +138,45 @@ set_target_properties ( ${LIB_NAME}
138138
Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR} )
139139

140140
#-------------------------------------
141-
# Build the documentation with ROBODoc
141+
# Build the documentation with FORD
142142
#-------------------------------------
143143
set ( SKIP_DOC_GEN FALSE CACHE BOOL
144-
"Disable building the API documentation with ROBODoc" )
144+
"Disable building the API documentation with FORD" )
145145
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." )
163167

164168
foreach ( SRC_FILE ${JF_LIB_SRCS} ${JF_TEST_SRCS} )
165-
list ( APPEND ROBO_DEPENDS "${SRC_FILE}" )
169+
list ( APPEND FORD_DEPENDS "${SRC_FILE}" )
166170
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" )
172176
add_custom_target ( documentation ALL
173-
DEPENDS ${ROBODOC_OUTPUTS} )
177+
DEPENDS ${FORD_OUTPUTS} )
174178
set ( INSTALL_API_DOCUMENTATION TRUE
175-
CACHE BOOL "Install ROBODoc generated documentation?" )
179+
CACHE BOOL "Install FORD generated documentation?" )
176180
if ( INSTALL_API_DOCUMENTATION )
177181
if ( USE_GNU_INSTALL_CONVENTION )
178182
install ( DIRECTORY "${DOC_DIR}/" DESTINATION "${CMAKE_INSTALL_DOCDIR}" )
@@ -182,7 +186,7 @@ if ( NOT SKIP_DOC_GEN )
182186
endif ()
183187
else () # Not found
184188
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." )
186190
endif ()
187191
endif ()
188192

@@ -209,7 +213,7 @@ if ( ENABLE_TESTS )
209213
set ( DATA_DIR "${CMAKE_BINARY_DIR}/files" )
210214

211215
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}" )
213217

214218
# Validate input
215219
if ( JSONLINT )
@@ -222,7 +226,7 @@ if ( ENABLE_TESTS )
222226
get_filename_component ( TESTNAME "${VALID_JSON}" NAME )
223227
add_test ( NAME validate-${TESTNAME}
224228
WORKING_DIRECTORY "${DATA_DIR}/inputs"
225-
COMMAND ${JSONLINT} "${VALID_JSON}" )
229+
COMMAND ${JSONLINT} "--allow=nonescape-characters" "${VALID_JSON}" )
226230
endforeach ()
227231

228232
foreach ( INVALID ${INVALID_JSON} )
@@ -267,7 +271,7 @@ if ( ENABLE_TESTS )
267271
get_filename_component ( TESTNAME ${JSON_FILE} NAME )
268272
add_test ( NAME validate-output-${TESTNAME}
269273
WORKING_DIRECTORY "${DATA_DIR}"
270-
COMMAND ${JSONLINT} ${TESTNAME} )
274+
COMMAND ${JSONLINT} "--allow=nonescape-characters" ${TESTNAME} )
271275
set_property ( TEST validate-output-${TESTNAME}
272276
APPEND
273277
PROPERTY

0 commit comments

Comments
 (0)