Генерация документации с помощью Breathe

This commit is contained in:
Andrei Astafev 2019-03-31 13:52:29 +03:00
parent 8e5a62199b
commit 2980180da0
2 changed files with 71 additions and 49 deletions

View File

@ -1,57 +1,79 @@
find_package(Doxygen REQUIRED) set(BUILD_BREATHE_DOC AUTO CACHE STRING "Enable documntation in Breathe format")
find_package(Perl REQUIRED) set_property(CACHE BUILD_BREATHE_DOC PROPERTY STRINGS AUTO ON OFF)
set(Python_ADDITIONAL_VERSIONS 3.7 3.6 3.5 3.4 3.3 3.2)
find_package(PythonInterp REQUIRED) if(BUILD_BREATHE_DOC STREQUAL AUTO)
find_package(Sphinx REQUIRED) find_package(Doxygen)
include(FindPythonModule) find_package(Perl)
find_python_module(breathe REQUIRED) set(Python_ADDITIONAL_VERSIONS 3.7 3.6 3.5 3.4 3.3 3.2)
find_package(PythonInterp)
find_package(Sphinx)
include(FindPythonModule)
find_python_module(breathe)
find_python_module(recommonmark)
if(DOXYGEN_FOUND AND PERL_FOUND AND SPHINX_FOUND AND breathe AND recommonmark)
set(BUILD_BREATHE_DOC ON CACHE STRING "Enable documntation in Breathe format" FORCE)
endif()
elseif(BUILD_BREATHE_DOC)
find_package(Doxygen REQUIRED)
find_package(Perl REQUIRED)
set(Python_ADDITIONAL_VERSIONS 3.7 3.6 3.5 3.4 3.3 3.2)
find_package(PythonInterp REQUIRED)
find_package(Sphinx REQUIRED)
include(FindPythonModule)
find_python_module(breathe REQUIRED)
find_python_module(recommonmark REQUIRED)
set(BUILD_BREATHE_DOC ON CACHE STRING "Enable documntation in Breathe format" FORCE)
else()
set(BUILD_BREATHE_DOC OFF CACHE STRING "Enable documntation in Breathe format" FORCE)
endif()
function(add_breathe_doc) function(add_breathe_doc)
set(options) if(BUILD_BREATHE_DOC AND CMAKE_BUILD_TYPE STREQUAL Release)
set(oneValueArgs set(options)
SOURCE_DIR set(oneValueArgs
BUILD_DIR SOURCE_DIR
CACHE_DIR BUILD_DIR
HTML_DIR CACHE_DIR
DOXY_FILE HTML_DIR
CONF_FILE DOXY_FILE
TARGET_NAME CONF_FILE
COMMENT TARGET_NAME
) COMMENT
set(multiValueArgs) )
set(multiValueArgs)
cmake_parse_arguments(BREATHE_DOC cmake_parse_arguments(BREATHE_DOC
"${options}" "${options}"
"${oneValueArgs}" "${oneValueArgs}"
"${multiValueArgs}" "${multiValueArgs}"
${ARGN} ${ARGN}
) )
configure_file( configure_file(
${BREATHE_DOC_CONF_FILE} ${BREATHE_DOC_CONF_FILE}
${BREATHE_DOC_BUILD_DIR}/conf.py ${BREATHE_DOC_BUILD_DIR}/conf.py
@ONLY @ONLY
) )
configure_file( configure_file(
${BREATHE_DOC_DOXY_FILE} ${BREATHE_DOC_DOXY_FILE}
${BREATHE_DOC_BUILD_DIR}/Doxyfile ${BREATHE_DOC_BUILD_DIR}/Doxyfile
@ONLY @ONLY
) )
add_custom_target(${BREATHE_DOC_TARGET_NAME} add_custom_target(${BREATHE_DOC_TARGET_NAME}
COMMAND ALL
COMMAND
${SPHINX_EXECUTABLE} ${SPHINX_EXECUTABLE}
-q -q
-b html -b html
-c ${BREATHE_DOC_BUILD_DIR} -c ${BREATHE_DOC_BUILD_DIR}
-d ${BREATHE_DOC_CACHE_DIR} -d ${BREATHE_DOC_CACHE_DIR}
${BREATHE_DOC_SOURCE_DIR} ${BREATHE_DOC_SOURCE_DIR}
${BREATHE_DOC_HTML_DIR} ${BREATHE_DOC_HTML_DIR}
COMMENT COMMENT
"Building ${BREATHE_DOC_TARGET_NAME} documentation with Breathe, Sphinx and Doxygen" "Building ${BREATHE_DOC_TARGET_NAME} documentation with Breathe, Sphinx and Doxygen"
VERBATIM VERBATIM
) )
endif()
message(STATUS "Added ${BREATHE_DOC_TARGET_NAME} [Breathe+Sphinx+Doxygen] target to build documentation")
endfunction() endfunction()

View File

@ -33,7 +33,7 @@ include(CMLibBuildTypes)
include(CMLibCodeAnalysisPvsStudio) include(CMLibCodeAnalysisPvsStudio)
include(cotire) include(cotire)
#include(CMLibBreathe) include(CMLibBreathe)
include(CMLibQtTranslation) include(CMLibQtTranslation)
include(CMLibToday) include(CMLibToday)
include(CMLibConfigHPPGenerate) include(CMLibConfigHPPGenerate)