| 1 |
option(VXL_BUILD_DOCUMENTATION |
| 2 |
"Build doxygen-based code documentation." OFF) |
| 3 |
|
| 4 |
mark_as_advanced(VXL_BUILD_DOCUMENTATION) |
| 5 |
# Dummy stubs to avoid VXL_BUILD_DOCUMENTATION ocnditionals around calls. |
| 6 |
function(doxygen_add_book) |
| 7 |
endfunction() |
| 8 |
function(doxygen_add_package) |
| 9 |
endfunction() |
| 10 |
function(doxygen_add_library) |
| 11 |
endfunction() |
| 12 |
|
| 13 |
if(VXL_BUILD_DOCUMENTATION) |
| 14 |
#------------------------------------------------------------------- |
| 15 |
# helper functions |
| 16 |
#------------------------------------------------------------------- |
| 17 |
# doxygen_add_book(<package> <description>) |
| 18 |
# |
| 19 |
# - package : package or site (e.g., core, contrib/mul, etc.) |
| 20 |
# - description : comment describing the package |
| 21 |
# |
| 22 |
# Example usage: |
| 23 |
# |
| 24 |
# doxygen_add_package(contrib/mul |
| 25 |
# "Manchester University Libraries overview documentation" |
| 26 |
# ) |
| 27 |
function(doxygen_add_book _book _description) |
| 28 |
if(TEXI2HTML_EXECUTABLE) |
| 29 |
string(REPLACE / _ bookname ${_book}) |
| 30 |
file(APPEND "${CMAKE_BINARY_DIR}/doxygen_configuration.cmake" |
| 31 |
"set(DOXYGEN_BOOK_LIST \${DOXYGEN_BOOK_LIST} ${_book})\n" |
| 32 |
"set(DOXYGEN_${bookname}_BOOK_DESCRIPTION\n" |
| 33 |
" \"${_description}\")\n" |
| 34 |
) |
| 35 |
endif() |
| 36 |
endfunction() |
| 37 |
|
| 38 |
# doxygen_add_package(<package> <description>) |
| 39 |
# |
| 40 |
# - package : package or site (e.g., core, contrib/mul, etc.) |
| 41 |
# - description : comment describing the package |
| 42 |
# |
| 43 |
# Example usage: |
| 44 |
# |
| 45 |
# doxygen_add_package(contrib/mul |
| 46 |
# "Manchester University Libraries" |
| 47 |
# ) |
| 48 |
function(doxygen_add_package _package _description) |
| 49 |
string(REPLACE / _ packname ${_package}) |
| 50 |
file(APPEND "${CMAKE_BINARY_DIR}/doxygen_configuration.cmake" |
| 51 |
"set(DOXYGEN_PACKAGE_LIST \${DOXYGEN_PACKAGE_LIST} ${_package})\n" |
| 52 |
"set(DOXYGEN_${packname}_DESCRIPTION \"${_description}\")\n" |
| 53 |
) |
| 54 |
endfunction() |
| 55 |
|
| 56 |
# doxygen_add_library(<lib> |
| 57 |
# [DEPENDS <dep1> <dep2> ...] |
| 58 |
# [PACKAGE <package>] |
| 59 |
# [DESCRIPTION <description>] |
| 60 |
# ) |
| 61 |
# |
| 62 |
# - lib : name of library |
| 63 |
# - package : package to which it belongs |
| 64 |
# - depN : dependencies of this lib |
| 65 |
# - description : comment describing the library |
| 66 |
# |
| 67 |
# Example usage: |
| 68 |
# |
| 69 |
# doxygen_add_library(contrib/gel/mrc/vpgl |
| 70 |
# DEPENDS core/vcsl core/vgl core/vnl core/vbl |
| 71 |
# PACKAGE contrib/gel |
| 72 |
# DESCRIPTION "Photogrammetry Library" |
| 73 |
# ) |
| 74 |
function(doxygen_add_library _library) |
| 75 |
# parse arguments |
| 76 |
set(DEPENDS) |
| 77 |
set(PACKAGE) |
| 78 |
set(DESCRIPTION) |
| 79 |
set(active_option) |
| 80 |
set(options_list PACKAGE DEPENDS DESCRIPTION) |
| 81 |
foreach(arg ${ARGN}) |
| 82 |
list(FIND options_list ${arg} result) |
| 83 |
if(result EQUAL -1) |
| 84 |
set(${active_option} ${${active_option}} ${arg}) |
| 85 |
if(NOT "${active_option}" STREQUAL "DEPENDS") |
| 86 |
set(active_option) |
| 87 |
endif() |
| 88 |
else() |
| 89 |
set(active_option ${arg}) |
| 90 |
endif() |
| 91 |
endforeach() |
| 92 |
if(NOT PACKAGE) |
| 93 |
set(PACKAGE other) |
| 94 |
endif() |
| 95 |
|
| 96 |
# start work |
| 97 |
set(library ${_library}) |
| 98 |
|
| 99 |
string(REPLACE / _ libname ${library}) |
| 100 |
string(REPLACE / _ packname ${PACKAGE}) |
| 101 |
|
| 102 |
get_filename_component(prefix ${library} NAME) |
| 103 |
set(prefix ${prefix}_) |
| 104 |
|
| 105 |
# NOTE: tagfiles will be resolved in doxygen_makeall.cmake |
| 106 |
set(tagfiles @tagfiles@) |
| 107 |
configure_file( |
| 108 |
"${DOXYGEN_SCRIPT_DIR}/doxyfile.in" |
| 109 |
"${CMAKE_BINARY_DIR}/doxy/output/doxyfile.${libname}" |
| 110 |
@ONLY |
| 111 |
) |
| 112 |
|
| 113 |
file(APPEND "${CMAKE_BINARY_DIR}/doxygen_configuration.cmake" |
| 114 |
"set(DOXYGEN_LIBRARY_LIST\n" |
| 115 |
" \${DOXYGEN_LIBRARY_LIST} ${library})\n" |
| 116 |
"set(DOXYGEN_${libname}_DEPS \"${DEPENDS}\")\n" |
| 117 |
"set(DOXYGEN_${libname}_DESCRIPTION \"${DESCRIPTION}\")\n" |
| 118 |
"set(DOXYGEN_${packname}_LIBRARY_LIST\n" |
| 119 |
" \${DOXYGEN_${packname}_LIBRARY_LIST} ${library})\n" |
| 120 |
) |
| 121 |
endfunction() |
| 122 |
|
| 123 |
#------------------------------------------------------------------- |
| 124 |
# find packages needed |
| 125 |
#------------------------------------------------------------------- |
| 126 |
find_package(Doxygen REQUIRED) |
| 127 |
find_package(Perl REQUIRED) |
| 128 |
|
| 129 |
find_program(TEXI2HTML_EXECUTABLE texi2html) |
| 130 |
if(NOT TEXI2HTML_EXECUTABLE) |
| 131 |
message(WARNING "Texi2html not found; no books will be built.") |
| 132 |
endif() |
| 133 |
|
| 134 |
find_package(Subversion QUIET) |
| 135 |
find_program(PSTOPNM_EXECUTABLE pstopnm) |
| 136 |
find_program(PNMTOPNG_EXECUTABLE pnmtopng) |
| 137 |
if(PSTOPNM_EXECUTABLE AND PNMTOPNG_EXECUTABLE) |
| 138 |
set(NetPBM_FOUND TRUE) |
| 139 |
else() |
| 140 |
find_package(ImageMagick QUIET COMPONENTS convert) |
| 141 |
endif() |
| 142 |
|
| 143 |
#------------------------------------------------------------------- |
| 144 |
# |
| 145 |
#------------------------------------------------------------------- |
| 146 |
# FIXME: Should others be cached?: DOXYGEN_STYLESHEET. |
| 147 |
set(DOXYGEN_OUTPUT_DIR "${CMAKE_BINARY_DIR}/doxy" |
| 148 |
CACHE PATH "Path to your doxygen output." |
| 149 |
) |
| 150 |
set(DOXYGEN_INDEX_FILE index.html |
| 151 |
CACHE STRING "Name of your multi-lib global index." |
| 152 |
) |
| 153 |
set(DOXYGEN_MERGE_DOCS_WITH "" |
| 154 |
CACHE STRING "Merge documentation to existing index." |
| 155 |
) |
| 156 |
|
| 157 |
get_filename_component(DOXYGEN_SCRIPT_DIR |
| 158 |
"${CMAKE_CURRENT_LIST_FILE}" PATH |
| 159 |
) |
| 160 |
set(DOXYGEN_SOURCE_DIR "${VXL_ROOT_SOURCE_DIR}") |
| 161 |
set(DOXYGEN_INPUT_FILTER "${DOXYGEN_SCRIPT_DIR}/vxl_doxy.pl") |
| 162 |
set(DOXYGEN_STYLESHEET) # FIXME: This is not really used so far... |
| 163 |
if(DOXYGEN_DOT_FOUND) |
| 164 |
option(DOXYGEN_USE_GRAPHVIZ |
| 165 |
"Use graphviz to generate class diagrams" ON) |
| 166 |
if(DOXYGEN_USE_GRAPHVIZ) |
| 167 |
set(DOXYGEN_USE_DOT YES) |
| 168 |
else() |
| 169 |
set(DOXYGEN_USE_DOT NO) |
| 170 |
endif() |
| 171 |
endif() |
| 172 |
|
| 173 |
# make configuration loadable when running build_doxygen_doc target |
| 174 |
file(WRITE "${CMAKE_BINARY_DIR}/doxygen_configuration.cmake" |
| 175 |
"# Doxygen configuration variables for:\n" |
| 176 |
"# ${DOXYGEN_SCRIPT_DIR}/doxygen_makeall.cmake\n" |
| 177 |
"# *** This is a auto-generated file. DO NOT edit! ***\n" |
| 178 |
"\n" |
| 179 |
"set(Subversion_FOUND ${Subversion_FOUND})\n" |
| 180 |
"set(Subversion_SVN_EXECUTABLE ${Subversion_SVN_EXECUTABLE})\n" |
| 181 |
"\n" |
| 182 |
"set(PERL_EXECUTABLE ${PERL_EXECUTABLE})\n" |
| 183 |
"set(TEXI2HTML_EXECUTABLE ${TEXI2HTML_EXECUTABLE})\n" |
| 184 |
"set(NetPBM_FOUND ${NetPBM_FOUND})\n" |
| 185 |
"set(PSTOPNM_EXECUTABLE ${PSTOPNM_EXECUTABLE})\n" |
| 186 |
"set(PNMTOPNG_EXECUTABLE ${PNMTOPNG_EXECUTABLE})\n" |
| 187 |
"set(ImageMagick_FOUND ${ImageMagick_FOUND})\n" |
| 188 |
"set(ImageMagick_convert_EXECUTABLE ${ImageMagick_convert_EXECUTABLE})\n" |
| 189 |
"\n" |
| 190 |
"set(DOXYGEN_EXECUTABLE ${DOXYGEN_EXECUTABLE})\n" |
| 191 |
"set(DOXYGEN_OUTPUT_DIR ${DOXYGEN_OUTPUT_DIR})\n" |
| 192 |
"set(DOXYGEN_INDEX_FILE ${DOXYGEN_INDEX_FILE})\n" |
| 193 |
"set(DOXYGEN_MERGE_DOCS_WITH ${DOXYGEN_MERGE_DOCS_WITH})\n" |
| 194 |
"set(DOXYGEN_SCRIPT_DIR ${DOXYGEN_SCRIPT_DIR})\n" |
| 195 |
"set(DOXYGEN_SOURCE_DIR ${DOXYGEN_SOURCE_DIR})\n" |
| 196 |
"set(DOXYGEN_LIBRARY_LIST)\n" |
| 197 |
"set(DOXYGEN_BOOK_LIST)\n" |
| 198 |
"\n" |
| 199 |
#"set( ${})\n" |
| 200 |
) |
| 201 |
|
| 202 |
# prepare header for use by doxygen |
| 203 |
set(title "\$title") |
| 204 |
configure_file( |
| 205 |
"${DOXYGEN_SCRIPT_DIR}/doxy_header.html" |
| 206 |
"${CMAKE_BINARY_DIR}/doxy/output/doxy_header.html" |
| 207 |
) |
| 208 |
|
| 209 |
#------------------------------------------------------------------- |
| 210 |
# Add doxygen target |
| 211 |
# Pivot on version 2.6.3 - newer CMake's support "SOURCES" option on |
| 212 |
# the "add_custom_target" command. |
| 213 |
# |
| 214 |
# Using CMAKE_VERSION in the following test is more to the point, |
| 215 |
# but it is not supported in V2.6.3 and earlier versions of CMAKE. |
| 216 |
# |
| 217 |
# The CMAKE_MINIMUM_REQUIRED_VERSION can differ from what is set in the top |
| 218 |
# level CMake file when VXL is imported into other projects that use CMake. |
| 219 |
# When building VXL as a stand-alone library, the CMAKE_MINIMUM_REQUIRED_VERSION |
| 220 |
# value is set from the top level CMakeList.txt file. When the VXL |
| 221 |
# export config is used by other projects, |
| 222 |
# the CMAKE_MINIMUM_REQUIRED_VERSION is set from the top level cmake file |
| 223 |
# for that project, where the CMAKE_MINIMUM_REQUIRED_VERSION may be greater than |
| 224 |
# V2.6.3. If it is greater, then we can use the enhanced version of add_custom_target() |
| 225 |
# that supports the SOURCES ketword. |
| 226 |
#------------------------------------------------------------------- |
| 227 |
set( doxygen_sources ) |
| 228 |
if(CMAKE_MINIMUM_REQUIRED_VERSION GREATER 2.6.3) |
| 229 |
# this file does not exist in clean build |
| 230 |
if( NOT EXISTS ${CMAKE_BINARY_DIR}/doxygen_last_build_rev.cmake ) |
| 231 |
file(WRITE "${CMAKE_BINARY_DIR}/doxygen_last_build_rev.cmake" |
| 232 |
"# *** This is a auto-generated file. DO NOT edit! ***\n\n" ) |
| 233 |
endif() |
| 234 |
|
| 235 |
set( doxygen_sources |
| 236 |
SOURCES |
| 237 |
"${DOXYGEN_SCRIPT_DIR}/doxygen.cmake" |
| 238 |
"${DOXYGEN_SCRIPT_DIR}/doxygen_makeall.cmake" |
| 239 |
"${DOXYGEN_SCRIPT_DIR}/doxyfile.in" |
| 240 |
"${DOXYGEN_SCRIPT_DIR}/doxy_header.html" |
| 241 |
"${DOXYGEN_SCRIPT_DIR}/vxl_doxy.pl" |
| 242 |
"${CMAKE_BINARY_DIR}/doxygen_configuration.cmake" |
| 243 |
"${CMAKE_BINARY_DIR}/doxygen_last_build_rev.cmake" |
| 244 |
"${CMAKE_BINARY_DIR}/doxygen_last_build_rev.cmake" |
| 245 |
) |
| 246 |
endif() |
| 247 |
|
| 248 |
add_custom_target(build_doxygen_doc |
| 249 |
${CMAKE_COMMAND} -P "${DOXYGEN_SCRIPT_DIR}/doxygen_makeall.cmake" |
| 250 |
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" |
| 251 |
COMMENT "Build Doxygen Documentation" |
| 252 |
VERBATIM |
| 253 |
${doxygen_sources} |
| 254 |
) |
| 255 |
|
| 256 |
endif() |