2022-05-06 09:49:46 +00:00
|
|
|
include_guard(GLOBAL)
|
|
|
|
|
|
|
|
|
2021-12-12 19:37:50 +00:00
|
|
|
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)
|
2021-12-12 18:04:19 +00:00
|
|
|
|
2021-12-12 19:37:50 +00:00
|
|
|
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()
|
2021-12-12 18:04:19 +00:00
|
|
|
else()
|
|
|
|
set(BREATHE_FOUND OFF CACHE STRING "Breathe documentation generator disabled" FORCE)
|
|
|
|
endif()
|
|
|
|
|
2021-12-12 19:37:50 +00:00
|
|
|
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()
|
|
|
|
|
|
|
|
if(NOT TARGET ${_target})
|
|
|
|
set(options)
|
|
|
|
set(oneValueArgs COMMENT)
|
|
|
|
set(multiValueArgs)
|
|
|
|
cmake_parse_arguments(_arg "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
2021-12-12 18:04:19 +00:00
|
|
|
|
2021-12-12 19:37:50 +00:00
|
|
|
set(BREATHE_DIR ${CMAKE_BINARY_DIR}/doc/breathe)
|
|
|
|
set(BREATHE_CONF_DIR ${BREATHE_DIR}/conf)
|
|
|
|
set(BREATHE_DOXYGEN_DIR ${BREATHE_DIR}/doxygen)
|
2021-12-12 18:04:19 +00:00
|
|
|
set(GENERATE_XML YES)
|
|
|
|
set(GENERATE_HTML NO)
|
|
|
|
set(GENERATE_LATEX NO)
|
2021-12-12 19:37:50 +00:00
|
|
|
set(CONF_FILE ${MYX_CMAKE_FUNCTIONS_DIR}/doc/breathe-conf.py.in)
|
|
|
|
set(DOXY_FILE ${MYX_CMAKE_FUNCTIONS_DIR}/doc/Doxyfile.in)
|
2021-12-12 18:04:19 +00:00
|
|
|
|
2021-12-12 19:37:50 +00:00
|
|
|
configure_file(${CONF_FILE} ${BREATHE_CONF_DIR}/conf.py @ONLY)
|
|
|
|
configure_file(${DOXY_FILE} ${BREATHE_DOXYGEN_DIR}/Doxyfile @ONLY)
|
2021-12-12 18:04:19 +00:00
|
|
|
|
2021-12-12 19:37:50 +00:00
|
|
|
add_custom_target(${_target}
|
2021-12-12 18:04:19 +00:00
|
|
|
VERBATIM
|
2021-12-12 19:37:50 +00:00
|
|
|
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")
|
2021-12-12 18:04:19 +00:00
|
|
|
|
2021-12-12 19:37:50 +00:00
|
|
|
set(INDEX_MD_FILE ${CMAKE_HOME_DIRECTORY}/doc/breathe/index.md.in)
|
2021-12-12 18:04:19 +00:00
|
|
|
if(EXISTS ${INDEX_MD_FILE})
|
2021-12-12 19:37:50 +00:00
|
|
|
configure_file(${INDEX_MD_FILE} ${BREATHE_DOXYGEN_DIR}/index.md @ONLY)
|
|
|
|
file(GLOB MD_FILES ${CMAKE_HOME_DIRECTORY}/doc/breathe/*.md)
|
2021-12-12 18:04:19 +00:00
|
|
|
if(MD_FILES)
|
2021-12-12 19:37:50 +00:00
|
|
|
add_custom_command(TARGET ${_target} PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
|
|
${MD_FILES} ${BREATHE_DOXYGEN_DIR})
|
2021-12-12 18:04:19 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2021-12-12 19:37:50 +00:00
|
|
|
set(INDEX_RST_FILE ${CMAKE_HOME_DIRECTORY}/doc/breathe/index.rst.in)
|
2021-12-12 18:04:19 +00:00
|
|
|
if(EXISTS ${INDEX_RST_FILE})
|
2021-12-12 19:37:50 +00:00
|
|
|
configure_file(${INDEX_RST_FILE} ${BREATHE_DOXYGEN_DIR}/index.rst @ONLY)
|
2021-12-12 18:04:19 +00:00
|
|
|
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
|
2021-12-12 19:37:50 +00:00
|
|
|
${RST_FILES} ${BREATHE_DOXYGEN_DIR})
|
2021-12-12 18:04:19 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
2021-12-12 19:37:50 +00:00
|
|
|
|
2021-12-22 07:39:17 +00:00
|
|
|
if(NOT TARGET myx-cmake-doc-breathe)
|
|
|
|
add_custom_target(myx-cmake-doc-breathe)
|
|
|
|
endif()
|
|
|
|
add_dependencies(myx-cmake-doc-breathe ${_target})
|
|
|
|
|
2021-12-12 19:37:50 +00:00
|
|
|
install(DIRECTORY ${CMAKE_BINARY_DIR}/doc/breathe/html
|
2021-12-12 18:04:19 +00:00
|
|
|
COMPONENT doc OPTIONAL
|
|
|
|
DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/breathe)
|
|
|
|
else()
|
2021-12-12 20:11:20 +00:00
|
|
|
message(STATUS "MyxCMake:")
|
2021-12-12 18:04:19 +00:00
|
|
|
add_custom_target(${target} VERBATIM COMMENT " Breathe is not found. Skipping target ${target} build")
|
|
|
|
endif()
|
|
|
|
endfunction()
|