|
|
@ -2,44 +2,36 @@
|
|
|
|
# Find the Sphinx documentation generator
|
|
|
|
# Find the Sphinx documentation generator
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# This modules defines
|
|
|
|
# This modules defines
|
|
|
|
# SPHINX_EXECUTABLE
|
|
|
|
# Sphinx_EXECUTABLE
|
|
|
|
# SPHINX_FOUND
|
|
|
|
# Sphinx_FOUND
|
|
|
|
|
|
|
|
# function Sphinx_add_target
|
|
|
|
find_program(SPHINX_EXECUTABLE
|
|
|
|
# function Sphinx_add_targets
|
|
|
|
NAMES sphinx-build
|
|
|
|
#
|
|
|
|
PATHS
|
|
|
|
|
|
|
|
/usr/bin
|
|
|
|
|
|
|
|
/usr/local/bin
|
|
|
|
|
|
|
|
/opt/local/bin
|
|
|
|
|
|
|
|
DOC "Sphinx documentation generator"
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( NOT SPHINX_EXECUTABLE )
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
set(_Python_VERSIONS
|
|
|
|
include(CMakeParseArguments)
|
|
|
|
2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0 1.6 1.5
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach( _version ${_Python_VERSIONS} )
|
|
|
|
set(_sphinx_names sphinx-build)
|
|
|
|
set( _sphinx_NAMES sphinx-build-${_version} )
|
|
|
|
foreach(_version 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0 1.6 1.5)
|
|
|
|
|
|
|
|
list(APPEND _sphinx_names sphinx-build-${_version})
|
|
|
|
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
|
|
|
|
find_program( SPHINX_EXECUTABLE
|
|
|
|
find_program(Sphinx_EXECUTABLE
|
|
|
|
NAMES ${_sphinx_NAMES}
|
|
|
|
NAMES ${_sphinx_names}
|
|
|
|
PATHS
|
|
|
|
PATHS
|
|
|
|
/usr/bin
|
|
|
|
/usr/bin
|
|
|
|
/usr/local/bin
|
|
|
|
/usr/local/bin
|
|
|
|
/opt/loca/bin
|
|
|
|
/opt/local/bin
|
|
|
|
DOC "Sphinx documentation generator"
|
|
|
|
DOC "Sphinx documentation generator"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
endforeach()
|
|
|
|
mark_as_advanced(Sphinx_EXECUTABLE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
find_package_handle_standard_args(Sphinx DEFAULT_MSG
|
|
|
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Sphinx
|
|
|
|
SPHINX_EXECUTABLE
|
|
|
|
FOUND_VAR Sphinx_FOUND
|
|
|
|
|
|
|
|
REQUIRED_VARS Sphinx_EXECUTABLE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
option( SPHINX_HTML_OUTPUT "Build a single HTML with the whole content." ON )
|
|
|
|
option( SPHINX_HTML_OUTPUT "Build a single HTML with the whole content." ON )
|
|
|
|
option( SPHINX_DIRHTML_OUTPUT "Build HTML pages, but with a single directory per document." OFF )
|
|
|
|
option( SPHINX_DIRHTML_OUTPUT "Build HTML pages, but with a single directory per document." OFF )
|
|
|
|
option( SPHINX_HTMLHELP_OUTPUT "Build HTML pages with additional information for building a documentation collection in htmlhelp." OFF )
|
|
|
|
option( SPHINX_HTMLHELP_OUTPUT "Build HTML pages with additional information for building a documentation collection in htmlhelp." OFF )
|
|
|
@ -50,96 +42,43 @@ option( SPHINX_LATEX_OUTPUT "Build LaTeX sources that can be compiled to a PDF d
|
|
|
|
option( SPHINX_MAN_OUTPUT "Build manual pages in groff format for UNIX systems." OFF )
|
|
|
|
option( SPHINX_MAN_OUTPUT "Build manual pages in groff format for UNIX systems." OFF )
|
|
|
|
option( SPHINX_TEXT_OUTPUT "Build plain text files." OFF )
|
|
|
|
option( SPHINX_TEXT_OUTPUT "Build plain text files." OFF )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function(Sphinx_add_target target_name builder conf source destination)
|
|
|
|
mark_as_advanced(
|
|
|
|
add_custom_target( ${target_name} ALL
|
|
|
|
SPHINX_EXECUTABLE
|
|
|
|
COMMAND ${Sphinx_EXECUTABLE} -b ${builder} -c ${conf} ${source} ${destination}
|
|
|
|
SPHINX_HTML_OUTPUT
|
|
|
|
DEPENDS ${conf}/conf.py
|
|
|
|
SPHINX_DIRHTML_OUTPUT
|
|
|
|
COMMENT "Generating sphinx documentation: ${builder}"
|
|
|
|
SPHINX_HTMLHELP_OUTPUT
|
|
|
|
|
|
|
|
SPHINX_QTHELP_OUTPUT
|
|
|
|
|
|
|
|
SPHINX_DEVHELP_OUTPUT
|
|
|
|
|
|
|
|
SPHINX_EPUB_OUTPUT
|
|
|
|
|
|
|
|
SPHINX_LATEX_OUTPUT
|
|
|
|
|
|
|
|
SPHINX_MAN_OUTPUT
|
|
|
|
|
|
|
|
SPHINX_TEXT_OUTPUT
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function( Sphinx_add_target target_name builder conf source destination )
|
|
|
|
|
|
|
|
add_custom_target( ${target_name} ALL
|
|
|
|
|
|
|
|
COMMAND ${SPHINX_EXECUTABLE} -b ${builder}
|
|
|
|
|
|
|
|
-c ${conf}
|
|
|
|
|
|
|
|
${source}
|
|
|
|
|
|
|
|
${destination}
|
|
|
|
|
|
|
|
COMMENT "Generating sphinx documentation: ${builder}"
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
set_property(
|
|
|
|
set_property(DIRECTORY APPEND PROPERTY
|
|
|
|
DIRECTORY APPEND PROPERTY
|
|
|
|
ADDITIONAL_MAKE_CLEAN_FILES ${destination}
|
|
|
|
ADDITIONAL_MAKE_CLEAN_FILES
|
|
|
|
|
|
|
|
${destination}
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
endfunction()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
|
|
|
|
# Target dependencies can be optionally listed at the end.
|
|
|
|
# Usage:
|
|
|
|
function( Sphinx_add_targets target_base_name conf source base_destination )
|
|
|
|
#
|
|
|
|
|
|
|
|
# Sphinx_add_targets(NAME <base_targets_name>
|
|
|
|
set( _dependencies )
|
|
|
|
# SRC_DIR <path_to_doc>/
|
|
|
|
|
|
|
|
# DST_DIR <path_to_output_result>/
|
|
|
|
foreach( arg IN LISTS ARGN )
|
|
|
|
# CONFIG_DIR <path_to_conf.py>/
|
|
|
|
set( _dependencies ${_dependencies} ${arg} )
|
|
|
|
# [DEPENDENCIES dep1 dep2 dep3 ...]
|
|
|
|
endforeach()
|
|
|
|
# )
|
|
|
|
|
|
|
|
function(Sphinx_add_targets)
|
|
|
|
if( ${SPHINX_HTML_OUTPUT} )
|
|
|
|
set(options )
|
|
|
|
Sphinx_add_target( ${target_base_name}_html html ${conf} ${source} ${base_destination}/html )
|
|
|
|
set(one_value_keywords NAME SRC_DIR DST_DIR CONFIG_DIR)
|
|
|
|
|
|
|
|
set(multi_value_keywords DEPENDENCIES)
|
|
|
|
add_dependencies( ${target_base_name}_html ${_dependencies} )
|
|
|
|
CMAKE_PARSE_ARGUMENTS(OPT "${options}" "${one_value_keywords}" "${multi_value_keywords}" ${ARGN})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
if (NOT OPT_NAME OR NOT OPT_SRC_DIR OR NOT OPT_DST_DIR OR NOT OPT_CONFIG_DIR)
|
|
|
|
if( ${SPHINX_DIRHTML_OUTPUT} )
|
|
|
|
message(FATAL_ERROR "Arguments NAME, SRC_DIR, DST_DIR, CONFIG_DIR are required!")
|
|
|
|
Sphinx_add_target( ${target_base_name}_dirhtml dirhtml ${conf} ${source} ${base_destination}/dirhtml )
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
add_dependencies( ${target_base_name}_dirhtml ${_dependencies} )
|
|
|
|
foreach(_generator html dirhtml qthelp devhelp epub latex man text linkcheck)
|
|
|
|
endif()
|
|
|
|
string(TOUPPER ${_generator} _generator_uc)
|
|
|
|
|
|
|
|
if (SPHINX_${_generator_uc}_OUTPUT)
|
|
|
|
if( ${SPHINX_QTHELP_OUTPUT} )
|
|
|
|
Sphinx_add_target(${OPT_NAME}_${_generator} ${_generator} ${OPT_CONFIG_DIR} ${OPT_SRC_DIR} ${OPT_DST_DIR}/${_generator}/)
|
|
|
|
Sphinx_add_target( ${target_base_name}_qthelp qthelp ${conf} ${source} ${base_destination}/qthelp )
|
|
|
|
if (OPT_DEPENDENCIES)
|
|
|
|
|
|
|
|
add_dependencies(${OPT_NAME}_${_generator} ${OPT_DEPENDENCIES})
|
|
|
|
add_dependencies( ${target_base_name}_qthelp ${_dependencies} )
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
endforeach()
|
|
|
|
if( ${SPHINX_DEVHELP_OUTPUT} )
|
|
|
|
|
|
|
|
Sphinx_add_target( ${target_base_name}_devhelp devhelp ${conf} ${source} ${base_destination}/devhelp )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
add_dependencies( ${target_base_name}_devhelp ${_dependencies} )
|
|
|
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( ${SPHINX_EPUB_OUTPUT} )
|
|
|
|
|
|
|
|
Sphinx_add_target( ${target_base_name}_epub epub ${conf} ${source} ${base_destination}/epub )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
add_dependencies( ${target_base_name}_epub ${_dependencies} )
|
|
|
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( ${SPHINX_LATEX_OUTPUT} )
|
|
|
|
|
|
|
|
Sphinx_add_target( ${target_base_name}_latex latex ${conf} ${source} ${base_destination}/latex )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
add_dependencies( ${target_base_name}_latex ${_dependencies} )
|
|
|
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( ${SPHINX_MAN_OUTPUT} )
|
|
|
|
|
|
|
|
Sphinx_add_target( ${target_base_name}_man man ${conf} ${source} ${base_destination}/man )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
add_dependencies( ${target_base_name}_man ${_dependencies} )
|
|
|
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( ${SPHINX_TEXT_OUTPUT} )
|
|
|
|
|
|
|
|
Sphinx_add_target( ${target_base_name}_text text ${conf} ${source} ${base_destination}/text )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
add_dependencies( ${target_base_name}_text ${_dependencies} )
|
|
|
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( ${BUILD_TESTING} )
|
|
|
|
|
|
|
|
sphinx_add_target( ${target_base_name}_linkcheck linkcheck ${conf} ${source} ${base_destination}/linkcheck )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
add_dependencies( ${target_base_name}_linkcheck ${_dependencies} )
|
|
|
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
endfunction()
|
|
|
|
endfunction()
|
|
|
|