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
|
# Copyright (C) 2010 Florent Lamiraux CNRS.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# SPHINX_SETUP()
# --------------
#
# Look for Sphinx, add a custom rule to generate the documentation and
# install the documentation properly.
#
MACRO(SPHINX_SETUP)
FIND_PROGRAM(SPHINX_BUILD sphinx-build DOC
"Sphinx documentation generator tool")
IF (NOT SPHINX_BUILD)
MESSAGE(FATAL_ERROR "Failed to find sphinx")
ENDIF(NOT SPHINX_BUILD)
IF(UNIX)
SET(MAKE make)
ELSEIF(WIN32)
SET(MAKE nmake)
ELSE(UNIX)
MESSAGE(FATAL_ERROR
"sphinx documentation generation not supported on this platform.")
ENDIF(UNIX)
IF(MSVC)
# FIXME: it is impossible to trigger documentation installation
# at install, so put the target in ALL instead.
ADD_CUSTOM_TARGET(sphinx-doc ALL
COMMAND ${SPHINX_BUILD} -b html ${CMAKE_CURRENT_BINARY_DIR}/sphinx
${CMAKE_CURRENT_BINARY_DIR}/sphinx-html
COMMENT "Generating sphinx documentation"
)
ELSE(MSVC)
ADD_CUSTOM_TARGET(sphinx-doc
COMMAND ${SPHINX_BUILD} -b html ${CMAKE_CURRENT_BINARY_DIR}/sphinx
${CMAKE_CURRENT_BINARY_DIR}/sphinx-html
COMMENT "Generating sphinx documentation"
)
INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${MAKE} sphinx-doc)")
ENDIF(MSVC)
ADD_CUSTOM_COMMAND(
OUTPUT
${CMAKE_BINARY_DIR}/doc/sphinx-html
COMMAND ${SPHINX_BUILD} -b html ${CMAKE_CURRENT_BINARY_DIR}/sphinx
${CMAKE_CURRENT_BINARY_DIR}/sphinx-html
COMMENT "Generating sphinx documentation"
)
# Clean generated files.
SET_PROPERTY(
DIRECTORY APPEND PROPERTY
ADDITIONAL_MAKE_CLEAN_FILES
${CMAKE_BINARY_DIR}/doc/sphinx-html
)
# Install generated files.
INSTALL(DIRECTORY ${CMAKE_BINARY_DIR}/doc/sphinx-html
DESTINATION share/doc/${PROJECT_NAME})
IF(EXISTS ${CMAKE_SOURCE_DIR}/doc/pictures)
INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/doc/pictures
DESTINATION share/doc/${PROJECT_NAME}/sphinx-html)
ENDIF(EXISTS ${CMAKE_SOURCE_DIR}/doc/pictures)
LIST(APPEND LOGGING_WATCHED_VARIABLES
SPHINX_BUILD
)
ENDMACRO(SPHINX_SETUP)
# SPHINX_FINALIZE()
# -----------------
#
# Generate Sphinx related files.
#
MACRO(SPHINX_FINALIZE)
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/sphinx/index.rst.in
${CMAKE_CURRENT_BINARY_DIR}/sphinx/index.rst
@ONLY
)
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/sphinx/conf.py.in
${CMAKE_CURRENT_BINARY_DIR}/sphinx/conf.py
@ONLY
)
ENDMACRO(SPHINX_FINALIZE)
|