Правка функций для генерации документации

This commit is contained in:
Andrei Astafev 2019-08-17 11:19:08 +03:00
parent 7367dcfe4d
commit 6c0df3775a
2 changed files with 40 additions and 19 deletions

View File

@ -1,17 +1,27 @@
set(BUILD_BREATHE_DOC OFF CACHE STRING "Enable documntation in Breathe format") set(BREATHE_FOUND AUTO CACHE STRING "Enable Breathe documentation generator")
set_property(CACHE BUILD_BREATHE_DOC PROPERTY STRINGS ON OFF) set_property(CACHE BREATHE_FOUND PROPERTY STRINGS ON OFF AUTO)
find_package(Doxygen)
find_package(Perl)
set(Python_ADDITIONAL_VERSIONS 3.7 3.6 3.5 3.4 3.3 3.2)
find_package(PythonInterp)
if (PYTHONINTERP_FOUND)
find_package(Sphinx)
include(FindPythonModule)
find_python_module(breathe)
find_python_module(recommonmark)
if(DOXYGEN_FOUND AND PERL_FOUND AND PYTHONINTERP_FOUND AND SPHINX_FOUND AND breathe_FOUND AND recommonmark_FOUND)
set(BREATHE_FOUND ON CACHE STRING "Breathe documentation generator enabled" FORCE)
else()
set(BREATHE_FOUND OFF CACHE STRING "Breathe documentation generator disabled" FORCE)
endif()
else()
set(BREATHE_FOUND OFF CACHE FORCE)
endif()
function(add_breathe_target) function(add_breathe_target)
if(BUILD_BREATHE_DOC) if(BREATHE_FOUND)
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(options) set(options)
set(oneValueArgs SOURCE_DIR BUILD_DIR CACHE_DIR HTML_DIR DOXY_FILE CONF_FILE TARGET_NAME COMMENT) set(oneValueArgs SOURCE_DIR BUILD_DIR CACHE_DIR HTML_DIR DOXY_FILE CONF_FILE TARGET_NAME COMMENT)
set(multiValueArgs) set(multiValueArgs)
@ -28,5 +38,8 @@ function(add_breathe_target)
${_BREATHE_HTML_DIR} ${_BREATHE_HTML_DIR}
COMMENT "Building ${_BREATHE_TARGET_NAME} documentation with Breathe" COMMENT "Building ${_BREATHE_TARGET_NAME} documentation with Breathe"
) )
else()
add_custom_target(${_BREATHE_TARGET_NAME} VERBATIM
COMMENT "Breathe is not found. Skipping target ${_BREATHE_TARGET_NAME} build")
endif() endif()
endfunction() endfunction()

View File

@ -1,10 +1,16 @@
option(BUILD_DOXYGEN_DOC "Build documentation with Doxygen" OFF) set(DOXYGEN_FOUND AUTO CACHE STRING "Enable Doxygen documentation generator")
set_property(CACHE BUILD_DOXYGEN_DOC PROPERTY STRINGS ON OFF) set_property(CACHE DOXYGEN_FOUND PROPERTY STRINGS ON OFF AUTO)
find_package(Doxygen)
if (DOXYGEN_FOUND)
set(DOXYGEN_FOUND ON CACHE STRING "Doxygen documentation generator enabled" FORCE)
else()
set(DOXYGEN_FOUND OFF CACHE STRING "Doxygen documentation generator disabled" FORCE)
endif()
function(add_doxygen_target) function(add_doxygen_target)
if (BUILD_DOXYGEN_DOC) if (DOXYGEN_FOUND)
find_package(Doxygen REQUIRED)
set(options) set(options)
set(oneValueArgs TARGET_NAME IN OUT) set(oneValueArgs TARGET_NAME IN OUT)
set(multiValueArgs) set(multiValueArgs)
@ -18,7 +24,9 @@ function(add_doxygen_target)
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT} COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" COMMENT "Generating API documentation with Doxygen"
VERBATIM ) VERBATIM)
else()
add_custom_target(${_DOXYGEN_TARGET_NAME} VERBATIM
COMMENT "Doxygen is not found. Skipping target ${_BREATHE_TARGET_NAME} build")
endif() endif()
endfunction() endfunction()