Skip to content

Commit 330fa9d

Browse files
committed
Merge pull request #16 from zbeekman/bugfix
Bugfix for ROBODoc documentation generation with CMake
2 parents 3e570e0 + bb7a8c6 commit 330fa9d

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ bin/
22
lib/
33
builds/
44
*.mod
5-
*.o
5+
*.o
6+
documentation/

CMakeLists.txt

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,15 @@ set_target_properties ( ${LIB_NAME}-static
9494
PROPERTIES
9595
OUTPUT_NAME ${LIB_NAME}
9696
PREFIX lib
97-
VERSION ${VERSION} )
97+
VERSION ${VERSION}
98+
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib )
9899
set_target_properties ( ${LIB_NAME}
99100
PROPERTIES
100101
OUTPUT_NAME ${LIB_NAME}
101102
PREFIX lib
102103
SOVERSION ${VERSION_MAJOR}.${VERSION_MINOR}
103-
VERSION ${VERSION} )
104+
VERSION ${VERSION}
105+
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib )
104106

105107
#-------------------------------------
106108
# Build the documentation with ROBODoc
@@ -112,24 +114,28 @@ if ( NOT ROBODOC_SKIP_DOC_GEN )
112114
if ( ROBODOC ) # Found
113115
set ( ROBODOC_OPTIONS --tabsize 4 --index --toc --sections --syntaxcolors --source_line_numbers
114116
CACHE STRING "Options passed to robodoc to control building the documentation" )
115-
set ( DOC_DIR "${CMAKE_BINARY_DIR}/doc" )
117+
set ( DOC_DIR "${CMAKE_BINARY_DIR}/documentation" )
116118
set ( REQUIRED_ROBODOC_OPTIONS
117119
--src "${CMAKE_SOURCE_DIR}/src" --doc "${DOC_DIR}"
118120
--multidoc --html --ignore_case_when_linking
119121
--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}
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}
126133
COMMAND "${CMAKE_COMMAND}" -E make_directory "${DOC_DIR}" # Ensure DOC_DIR exists at build time
127134
COMMAND "${ROBODOC}" ${REQUIRED_ROBODOC_OPTIONS} ${ROBODOC_OPTIONS}
128135
DEPENDS "${CMAKE_SOURCE_DIR}/${JF_LIB_SRCS}"
129136
COMMENT "Building HTML documentation for ${CMAKE_PROJECT_NAME} using ROBODoc" )
130137
add_custom_target ( documentation ALL
131-
DEPENDS ${ROBO_OUTPUTS} )
132-
set_directory_properties ( PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES doc )
138+
DEPENDS ${ROBODOC_OUTPUTS} )
133139
else ( ROBODOC ) # Not found
134140
message ( WARNING
135141
"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." )

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ environment variable `FC` to point to your Fortran compiler, and
3737
create a build directory. Then `(cmake-gui|ccmake|cmake)
3838
/path/to/json-fortran-root` to configure, `make` to build and `make
3939
install` to optionally install. As long as the project is built with
40-
CMake other CMake projects can find it and link against it:
40+
CMake, other CMake projects can find it and link against it:
4141

4242
```CMake
4343
cmake_minimum_required ( VERSION 2.8 FATAL_ERROR )

0 commit comments

Comments
 (0)