Функции для документации

This commit is contained in:
Andrei Astafev 2019-12-03 19:20:42 +03:00
parent 023fb670f5
commit 8e75846a91
2 changed files with 71 additions and 71 deletions

View File

@ -1,19 +1,11 @@
set(BREATHE_FOUND AUTO CACHE STRING "Enable Breathe documentation generator") set(BREATHE_FOUND
set_property(CACHE BREATHE_FOUND AUTO
PROPERTY STRINGS CACHE STRING "Enable Breathe documentation generator")
ON set_property(CACHE BREATHE_FOUND PROPERTY STRINGS ON OFF AUTO)
OFF
AUTO)
find_package(Doxygen) find_package(Doxygen)
find_package(Perl) find_package(Perl)
set(Python_ADDITIONAL_VERSIONS set(Python_ADDITIONAL_VERSIONS 3.7 3.6 3.5 3.4 3.3 3.2)
3.7
3.6
3.5
3.4
3.3
3.2)
find_package(PythonInterp) find_package(PythonInterp)
if(PYTHONINTERP_FOUND) if(PYTHONINTERP_FOUND)
find_package(Sphinx) find_package(Sphinx)
@ -26,53 +18,65 @@ if(PYTHONINTERP_FOUND)
AND SPHINX_EXECUTABLE AND SPHINX_EXECUTABLE
AND breathe AND breathe
AND recommonmark) AND recommonmark)
set(BREATHE_FOUND ON CACHE STRING "Breathe documentation generator enabled" FORCE) set(BREATHE_FOUND
ON
CACHE STRING "Breathe documentation generator enabled" FORCE)
else() else()
set(BREATHE_FOUND OFF CACHE STRING "Breathe documentation generator disabled" FORCE) set(BREATHE_FOUND
OFF
CACHE STRING "Breathe documentation generator disabled" FORCE)
endif() endif()
else() else()
set(BREATHE_FOUND OFF CACHE STRING "Breathe documentation generator disabled" FORCE) set(BREATHE_FOUND
OFF
CACHE STRING "Breathe documentation generator disabled" FORCE)
endif() endif()
function(add_breathe_target) function(add_breathe_target)
set(options) set(options)
set(oneValueArgs set(oneValueArgs TARGET_NAME COMMENT)
TARGET_NAME
SOURCE_DIR
DOXY_FILE
CONF_FILE
OUTPUT_DIR
COMMENT)
set(multiValueArgs) set(multiValueArgs)
cmake_parse_arguments(_BREATHE cmake_parse_arguments(_BREATHE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
"${options}"
"${oneValueArgs}"
"${multiValueArgs}"
${ARGN})
if(BREATHE_FOUND) if(BREATHE_FOUND)
set(WORK_DIR ${CMAKE_BINARY_DIR}/_breathe) set(WORK_DIR ${CMAKE_BINARY_DIR}/_breathe)
set(BREATHE_DOCS_BUILD_DIR ${WORK_DIR}) set(BREATHE_DOCS_BUILD_DIR ${WORK_DIR})
set(GENERATE_XML YES) set(GENERATE_XML YES)
set(GENERATE_HTML NO) set(GENERATE_HTML NO)
set(GENERATE_LATEX NO) set(GENERATE_LATEX NO)
set(OUTPUT_DIRECTORY ${WORK_DIR}) set(GENERATE_SQLITE NO)
set(CONF_FILE ${CMAKE_SOURCE_DIR}/cmake/doc/breathe-conf.py.in)
set(DOXY_FILE ${CMAKE_SOURCE_DIR}/cmake/doc/Doxyfile.in)
configure_file(${_BREATHE_CONF_FILE} ${WORK_DIR}/conf.py @ONLY) configure_file(${CONF_FILE} ${WORK_DIR}/conf.py @ONLY)
configure_file(${_BREATHE_DOXY_FILE} ${WORK_DIR}/Doxyfile @ONLY) configure_file(${DOXY_FILE} ${WORK_DIR}/Doxyfile @ONLY)
add_custom_target(${_BREATHE_TARGET_NAME} VERBATIM add_custom_target(
COMMAND ${SPHINX_EXECUTABLE} ${_BREATHE_TARGET_NAME} VERBATIM
-q COMMAND
-b ${SPHINX_EXECUTABLE} -q -b html -c ${WORK_DIR} -d ${WORK_DIR}/cache ${WORK_DIR}
html ${CMAKE_BINARY_DIR}/doc/breathe
-c
${WORK_DIR}
-d
${WORK_DIR}/cache
${_BREATHE_SOURCE_DIR}
${_BREATHE_OUTPUT_DIR}
COMMENT "Building ${_BREATHE_TARGET_NAME} documentation with Breathe") COMMENT "Building ${_BREATHE_TARGET_NAME} documentation with Breathe")
set(INDEX_MD_FILE ${CMAKE_SOURCE_DIR}/doc/breathe/index.md.in)
if(EXISTS ${INDEX_MD_FILE})
configure_file(${INDEX_MD_FILE} ${WORK_DIR}/index.md @ONLY)
file(GLOB MD_FILES ${CMAKE_SOURCE_DIR}/doc/breathe/*.md)
if(MD_FILES)
add_custom_command(TARGET ${_BREATHE_TARGET_NAME} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${MD_FILES} ${WORK_DIR})
endif()
endif()
set(INDEX_RST_FILE ${CMAKE_SOURCE_DIR}/doc/breathe/index.rst.in)
if(EXISTS ${INDEX_RST_FILE})
configure_file(${INDEX_RST_FILE} ${WORK_DIR}/index.rst @ONLY)
file(GLOB RST_FILES ${CMAKE_SOURCE_DIR}/doc/breathe/*.rst)
if(RST_FILES)
add_custom_command(TARGET ${_BREATHE_TARGET_NAME} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${RST_FILES} ${WORK_DIR})
endif()
endif()
else() else()
add_custom_target(${_BREATHE_TARGET_NAME} VERBATIM add_custom_target(${_BREATHE_TARGET_NAME} VERBATIM
COMMENT "Breathe is not found. Skipping target ${_BREATHE_TARGET_NAME} build") COMMENT "Breathe is not found. Skipping target ${_BREATHE_TARGET_NAME} build")

View File

@ -1,50 +1,46 @@
set(DOXYGEN_FOUND AUTO CACHE STRING "Enable Doxygen documentation generator") set(DOXYGEN_FOUND
set_property(CACHE DOXYGEN_FOUND AUTO
PROPERTY STRINGS CACHE STRING "Enable Doxygen documentation generator")
ON set_property(CACHE DOXYGEN_FOUND PROPERTY STRINGS ON OFF AUTO)
OFF
AUTO)
find_package(Doxygen) find_package(Doxygen)
if(DOXYGEN_FOUND) if(DOXYGEN_FOUND)
set(DOXYGEN_FOUND ON CACHE STRING "Doxygen documentation generator enabled" FORCE) set(DOXYGEN_FOUND
ON
CACHE STRING "Doxygen documentation generator enabled" FORCE)
else() else()
set(DOXYGEN_FOUND OFF CACHE STRING "Doxygen documentation generator disabled" FORCE) set(DOXYGEN_FOUND
OFF
CACHE STRING "Doxygen documentation generator disabled" FORCE)
endif() endif()
function(add_doxygen_target) function(add_doxygen_target)
set(options) set(options)
set(oneValueArgs set(oneValueArgs TARGET_NAME SQLITE LATEX HTML)
TARGET_NAME
SOURCE_DIR
DOXY_FILE
OUTPUT_DIR
LATEX
HTML)
set(multiValueArgs) set(multiValueArgs)
cmake_parse_arguments(_DOXYGEN cmake_parse_arguments(_DOXYGEN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
"${options}"
"${oneValueArgs}"
"${multiValueArgs}"
${ARGN})
if(DOXYGEN_FOUND) if(DOXYGEN_FOUND)
set(GENERATE_XML NO) set(GENERATE_XML NO)
set(GENERATE_HTML NO) set(GENERATE_HTML NO)
set(GENERATE_LATEX NO) set(GENERATE_LATEX NO)
set(OUTPUT_DIRECTORY ${_DOXYGEN_OUTPUT_DIR}) set(GENERATE_SQLITE YES)
set(SOURCE_DIR ${_DOXYGEN_SOURCE_DIR})
if(_DOXYGEN_HTML) if(_DOXYGEN_HTML)
set(GENERATE_HTML YES) set(GENERATE_HTML YES)
endif() endif()
if(_DOXYGEN_LATEX) if(_DOXYGEN_LATEX)
set(GENERATE_LATEX YES) set(GENERATE_LATEX YES)
endif() endif()
if(_DOXYGEN_SQLITE)
set(GENERATE_SQLITE YES)
endif()
set(WORK_DIR ${CMAKE_BINARY_DIR}/_doxygen) set(WORK_DIR ${CMAKE_BINARY_DIR}/doc/doxygen)
configure_file(${_DOXYGEN_DOXY_FILE} ${WORK_DIR}/Doxyfile @ONLY) configure_file(${CMAKE_SOURCE_DIR}/cmake/doc/Doxyfile.in ${WORK_DIR}/Doxyfile @ONLY)
add_custom_target(${_DOXYGEN_TARGET_NAME} VERBATIM add_custom_target(
${_DOXYGEN_TARGET_NAME} VERBATIM
COMMAND "${CMAKE_COMMAND}" -E remove -f "${WORK_DIR}/doxygen_sqlite3.db"
COMMAND ${DOXYGEN_EXECUTABLE} ${WORK_DIR}/Doxyfile COMMAND ${DOXYGEN_EXECUTABLE} ${WORK_DIR}/Doxyfile
WORKING_DIRECTORY ${WORK_DIR} WORKING_DIRECTORY ${WORK_DIR}
COMMENT "Generating API documentation with Doxygen") COMMENT "Generating API documentation with Doxygen")