1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
#
# Find Sphinx
# Find Sphinx executable to build documentation
# Source: http://ericscottbarr.com/blog/2012/03/sphinx-and-cmake-beautiful-documentation-for-c-projects/
#
# Daniel Kastl 03/2013
#
set(SPHINX_THEME "haiku")
#set(SPHINX_THEME_DIR "_themes")
if(WITH_DOC)
find_package(Sphinx)
if (NOT SPHINX_FOUND)
message(WARNING "Sphinx not found. Cannot generate documentation!")
else()
if (SPHINX_VERSION VERSION_LESS 1.0)
message(WARNING "Your Sphinx version is too old!
This project requires Sphinx v1.0 or above to produce
proper documentation (you have v${SPHINX_VERSION}).
You will get output but it will have errors.")
endif()
if(NOT DEFINED SPHINX_THEME)
set(SPHINX_THEME default)
endif()
if(NOT DEFINED SPHINX_THEME_DIR)
set(SPHINX_THEME_DIR)
endif()
# configured documentation tools and intermediate build results
set(BINARY_BUILD_DIR "${PGROUTING_BINARY_DIR}/doc/_build")
message(STATUS "BINARY_BUILD_DIR = ${BINARY_BUILD_DIR}")
message(STATUS "PGROUTING_BINARY_DIR = ${PGROUTING_BINARY_DIR}")
# Sphinx cache with pickled ReST documents
set(SPHINX_CACHE_DIR "${PGROUTING_BINARY_DIR}/doc/_doctrees")
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/static" DESTINATION "${BINARY_BUILD_DIR}")
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/themes" DESTINATION "${BINARY_BUILD_DIR}")
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/CNAME" DESTINATION "${PGROUTING_BINARY_DIR}")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/index.html.in"
"${PGROUTING_BINARY_DIR}/doc/html/index.html")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/forward.html"
"${PGROUTING_BINARY_DIR}/doc/html/en/index.html")
# Add documentation to targets
set(DOC_TARGETS html)
option(BUILD_MAN "Create a target for building man pages." ON)
if (BUILD_MAN)
if (SPHINX_VERSION VERSION_LESS 1.0)
message(WARNING "Sphinx version 1.0 > is required to build man pages. You have v${SPHINX_VERSION}.")
else()
list(APPEND DOC_TARGETS man)
endif()
endif()
option(BUILD_LATEX "Create a target for building latex docs (to create PDF)." ON)
if (BUILD_LATEX)
find_package(LATEX)
if (NOT LATEX_COMPILER)
message("Couldn't find Latex, can't build latex docs using Sphinx")
else()
message(STATUS "LATEX_COMPILER = ${LATEX_COMPILER}")
list(APPEND DOC_TARGETS latex)
endif()
endif()
# The doc target will build all documentation targets.
add_custom_target(doc #ALL
COMMENT "Building documentation with Sphinx")
# add_custom_target(doc)
# Localization output directory
#set(SPHINX_I18N_DIR "${CMAKE_CURRENT_SOURCE_DIR}/i18n/pot")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in"
"${BINARY_BUILD_DIR}/conf.py"
@ONLY)
foreach (DOC_TARGET ${DOC_TARGETS})
add_custom_command(
TARGET doc POST_BUILD
COMMAND ${SPHINX_EXECUTABLE}
# -q # Enable for quiet mode
# -Q # Enable for even more quiet mode
-b ${DOC_TARGET}
-E # don't use a saved environment, always read all file
-a # write all files; default is to only write new and changed files
-d "${SPHINX_CACHE_DIR}"
-c "${BINARY_BUILD_DIR}"
"${PGROUTING_SOURCE_DIR}"
"${PGROUTING_BINARY_DIR}/doc/${DOC_TARGET}/en"
COMMENT "Generating ${DOC_TARGET} documentation ...")
endforeach()
if(BUILD_LATEX)
if(LATEX_COMPILER)
add_custom_command(
TARGET doc POST_BUILD
COMMAND pdflatex
-interaction=nonstopmode
"pgRoutingDocumentation.tex" > /dev/null 2>&1
WORKING_DIRECTORY "${PGROUTING_BINARY_DIR}/doc/latex/en"
COMMENT "Converting Latex to PDF format")
list(APPEND DOC_TARGETS pdf)
endif()
endif()
message("-- Building documentation enabled for: ${DOC_TARGETS}")
endif()
endif(WITH_DOC)
|