Начало работы с Breathe

This commit is contained in:
Andrei Astafev 2021-12-12 22:37:50 +03:00
parent 4b92732a3b
commit 20d372a25c
6 changed files with 88 additions and 67 deletions

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.0)
project(myx-cmake VERSION 0.2.6 LANGUAGES)
project(myx-cmake VERSION 0.3.0 LANGUAGES)
include(GNUInstallDirs)
file(WRITE ${CMAKE_SOURCE_DIR}/MyxCMake/MyxCMakeConfigVersion.cmake

View File

@ -1,74 +1,85 @@
set(BREATHE_FOUND AUTO CACHE STRING "Enable Breathe documentation generator")
set_property(CACHE BREATHE_FOUND PROPERTY STRINGS ON OFF AUTO)
function(myx_cmake_doc_breathe)
set(BREATHE_FOUND AUTO CACHE STRING "Enable Breathe documentation generator")
set_property(CACHE BREATHE_FOUND PROPERTY STRINGS ON OFF AUTO)
find_package(Doxygen)
find_package(Perl)
set(Python_ADDITIONAL_VERSIONS 3.9;3.8;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_EXECUTABLE
AND breathe
AND recommonmark)
set(BREATHE_FOUND ON CACHE STRING "Breathe documentation generator enabled" FORCE)
find_package(Doxygen)
find_package(Perl)
set(Python_ADDITIONAL_VERSIONS 3.11;3.10;3.9;3.8;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_EXECUTABLE
AND breathe
AND recommonmark)
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 STRING "Breathe documentation generator disabled" FORCE)
endif()
else()
set(BREATHE_FOUND OFF CACHE STRING "Breathe documentation generator disabled" FORCE)
endif()
function(myx_cmake_add_breathe_target target)
set(options)
set(oneValueArgs COMMENT)
set(multiValueArgs)
set(_target "myx-cmake-doc-breathe-${CMAKE_PROJECT_NAME}")
if(NOT BREATHE_FOUND)
message(STATUS "MyxCMake:")
add_custom_target(${_target} VERBATIM COMMENT " Breathe is not found. Skipping target ${_target} build")
return()
endif()
cmake_parse_arguments(_BREATHE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(BREATHE_FOUND)
set(WORK_DIR ${CMAKE_BINARY_DIR}/_breathe)
set(BREATHE_DOCS_BUILD_DIR ${WORK_DIR})
if(NOT TARGET ${_target})
set(options)
set(oneValueArgs COMMENT)
set(multiValueArgs)
cmake_parse_arguments(_arg "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set(BREATHE_DIR ${CMAKE_BINARY_DIR}/doc/breathe)
set(BREATHE_CONF_DIR ${BREATHE_DIR}/conf)
set(BREATHE_DOXYGEN_DIR ${BREATHE_DIR}/doxygen)
set(GENERATE_XML YES)
set(GENERATE_HTML NO)
set(GENERATE_LATEX NO)
set(CONF_FILE ${CMLIB_MODULE_DIR}/doxygen/breathe-conf.py.in)
set(DOXY_FILE ${CMLIB_MODULE_DIR}/doxygen/Doxyfile.in)
set(CONF_FILE ${MYX_CMAKE_FUNCTIONS_DIR}/doc/breathe-conf.py.in)
set(DOXY_FILE ${MYX_CMAKE_FUNCTIONS_DIR}/doc/Doxyfile.in)
configure_file(${CONF_FILE} ${WORK_DIR}/conf.py @ONLY)
configure_file(${DOXY_FILE} ${WORK_DIR}/Doxyfile @ONLY)
configure_file(${CONF_FILE} ${BREATHE_CONF_DIR}/conf.py @ONLY)
configure_file(${DOXY_FILE} ${BREATHE_DOXYGEN_DIR}/Doxyfile @ONLY)
add_custom_target(
${target}
add_custom_target(${_target}
VERBATIM
COMMAND ${SPHINX_EXECUTABLE} -q -b html -c ${WORK_DIR} -d ${WORK_DIR}/cache ${WORK_DIR}
${CMAKE_BINARY_DIR}/doc/breathe
COMMENT "Building ${target} documentation with Breathe")
DEPENDS ${DOXY_FILE}
DEPENDS ${CONF_FILE}
COMMAND "${CMAKE_COMMAND}" -E make_directory ${BREATHE_CONF_DIR}
COMMAND ${SPHINX_EXECUTABLE} -q -b html -c ${BREATHE_CONF_DIR}
-d ${BREATHE_DIR}/cache ${BREATHE_DOXYGEN_DIR} ${BREATHE_DIR}/html
COMMENT "Building ${CMAKE_PROJECT_NAME} documentation with Breathe")
set(INDEX_MD_FILE ${CMAKE_SOURCE_DIR}/doc/breathe/index.md.in)
set(INDEX_MD_FILE ${CMAKE_HOME_DIRECTORY}/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)
configure_file(${INDEX_MD_FILE} ${BREATHE_DOXYGEN_DIR}/index.md @ONLY)
file(GLOB MD_FILES ${CMAKE_HOME_DIRECTORY}/doc/breathe/*.md)
if(MD_FILES)
add_custom_command(TARGET ${target} PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different
${MD_FILES} ${WORK_DIR})
add_custom_command(TARGET ${_target} PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different
${MD_FILES} ${BREATHE_DOXYGEN_DIR})
endif()
endif()
set(INDEX_RST_FILE ${CMAKE_SOURCE_DIR}/doc/breathe/index.rst.in)
set(INDEX_RST_FILE ${CMAKE_HOME_DIRECTORY}/doc/breathe/index.rst.in)
if(EXISTS ${INDEX_RST_FILE})
configure_file(${INDEX_RST_FILE} ${WORK_DIR}/index.rst @ONLY)
configure_file(${INDEX_RST_FILE} ${BREATHE_DOXYGEN_DIR}/index.rst @ONLY)
file(GLOB RST_FILES ${CMAKE_SOURCE_DIR}/doc/breathe/*.rst)
if(RST_FILES)
add_custom_command(TARGET ${target} PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different
${RST_FILES} ${WORK_DIR})
${RST_FILES} ${BREATHE_DOXYGEN_DIR})
endif()
endif()
install(DIRECTORY ${CMAKE_BINARY_DIR}/doc/breathe/
install(DIRECTORY ${CMAKE_BINARY_DIR}/doc/breathe/html
COMPONENT doc OPTIONAL
DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/breathe)
else()

View File

@ -49,8 +49,8 @@ master_doc = 'index'
# General information about the project.
project = '@DOXYGEN_PROJECT_TITLE@'
author = '@AUTHOR_NAME@'
copyright = '@CMLIB_YEAR@, ' + author
author = '@MYX_CMAKE_AUTHOR_NAME@'
copyright = '© @MYX_CMAKE_YEAR@, ' + author
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
@ -112,7 +112,7 @@ html_sidebars = {
# -- Options for HTMLHelp output ------------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename = '@PROJECT_NAME@doc'
htmlhelp_basename = '@CMAKE_PROJECT_NAME@doc'
# -- Options for LaTeX output ---------------------------------------------
@ -138,7 +138,7 @@ latex_elements = {
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, '@PROJECT_NAME@.tex', '@PROJECT_NAME@ Documentation',
(master_doc, '@CMAKE_PROJECT_NAME@.tex', '@CMAKE_PROJECT_NAME@ Documentation',
author, 'manual'),
]
@ -146,7 +146,7 @@ latex_documents = [
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [(master_doc, '@PROJECT_NAME@', '@PROJECT_NAME@ Documentation', [author], 1)]
man_pages = [(master_doc, '@CMAKE_PROJECT_NAME@', '@CMAKE_PROJECT_NAME@ Documentation', [author], 1)]
# -- Options for Texinfo output -------------------------------------------
@ -154,11 +154,11 @@ man_pages = [(master_doc, '@PROJECT_NAME@', '@PROJECT_NAME@ Documentation', [aut
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, '@PROJECT_NAME@', '@PROJECT_NAME@ Documentation', author, '@PROJECT_NAME@',
(master_doc, '@CMAKE_PROJECT_NAME@', '@CMAKE_PROJECT_NAME@ Documentation', author, '@CMAKE_PROJECT_NAME@',
'One line description of project.', 'Miscellaneous'),
]
breathe_projects = {'@PROJECT_NAME@': '@BREATHE_DOCS_BUILD_DIR@/xml'}
breathe_projects = {'@CMAKE_PROJECT_NAME@': '@BREATHE_DOXYGEN_DIR@/xml'}
def run_doxygen(folder):
@ -174,7 +174,7 @@ def run_doxygen(folder):
def setup(app):
run_doxygen('@BREATHE_DOCS_BUILD_DIR@')
run_doxygen('@BREATHE_DOXYGEN_DIR@')
app.add_config_value('recommonmark_config', {
'enable_auto_toc_tree': True,
'enable_eval_rst': True,

View File

@ -12,7 +12,7 @@ include(MyxCMakeProjectVersion)
include(MyxCMakeRequiredVariables)
include(MyxCMakeGlobalFunctions)
include(MyxCMakeGlobalVariables)
include(MyxCMakeToday)
include(MyxCMakeDates)
include(MyxCMakeLSBInfo)
include(MyxCMakeCompiler)
include(MyxCMakeCompilerFlags)
@ -33,8 +33,8 @@ include(MyxCMakeAddSharedLibrary)
include(MyxCMakeAddStaticLibrary)
include(MyxCMakePkgConfig)
include(MyxCMakeNinjaGeneratorHelper)
include(CMLibDocDoxygen)
include(CMLibDocBreathe)
include(MyxCMakeDocDoxygen)
include(MyxCMakeDocBreathe)
include(MyxCMakeExternalProject)
include(MyxCMakeCPack)
include(MyxCMakeUninstall)

View File

@ -0,0 +1,18 @@
if(NOT MYX_CMAKE_TODAY)
if(WIN32)
execute_process(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE MYX_CMAKE_TODAY)
else()
execute_process(COMMAND "date" "+%d/%m/%Y" OUTPUT_VARIABLE MYX_CMAKE_TODAY)
endif()
string(REGEX REPLACE "(..)/(..)/(....).*" "\\3-\\2-\\1" MYX_CMAKE_TODAY ${MYX_CMAKE_TODAY})
endif()
if(NOT MYX_CMAKE_YEAR)
if(WIN32)
execute_process(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE MYX_CMAKE_YEAR)
else()
execute_process(COMMAND "date" "+%d/%m/%Y" OUTPUT_VARIABLE MYX_CMAKE_YEAR)
endif()
string(REGEX REPLACE "(..)/(..)/(....).*" "\\3" MYX_CMAKE_YEAR ${MYX_CMAKE_YEAR})
endif()

View File

@ -1,8 +0,0 @@
if(NOT TODAY)
if(WIN32)
execute_process(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE TODAY)
else()
execute_process(COMMAND "date" "+%d/%m/%Y" OUTPUT_VARIABLE TODAY)
endif()
string(REGEX REPLACE "(..)/(..)/(....).*" "\\3-\\2-\\1" TODAY ${TODAY})
endif()