This commit is contained in:
Andrei Astafev 2022-10-04 17:24:08 +03:00
parent 1910243bea
commit 33a6c7c718
3 changed files with 103 additions and 0 deletions

View File

@ -32,6 +32,7 @@ include(${MYX_CMAKE_LIB_DIR}/TargetSetup.cmake)
include(${MYX_CMAKE_LIB_DIR}/Qt5TargetSetup.cmake)
include(${MYX_CMAKE_LIB_DIR}/Uncrustify.cmake)
include(${MYX_CMAKE_LIB_DIR}/doc/Doxygen.cmake)
include(${MYX_CMAKE_LIB_DIR}/generators/GitInfoHeader.cmake)
include(${MYX_CMAKE_LIB_DIR}/generators/PrivateConfigHeader.cmake)

31
lib/doc/Doxyfile.in Normal file
View File

@ -0,0 +1,31 @@
PROJECT_NAME = @DOXYGEN_PROJECT_TITLE@
OUTPUT_DIRECTORY = @DOXYGEN_OUTPUT_DIRECTORY@
OUTPUT_LANGUAGE = @ARG_LANGUAGE@
STRIP_FROM_PATH = @PROJECT_SOURCE_DIR@
STRIP_FROM_INC_PATH = @PROJECT_SOURCE_DIR@
EXTRACT_ALL = YES
EXTRACT_PRIVATE = YES
EXTRACT_STATIC = YES
EXTRACT_LOCAL_METHODS = YES
INPUT = "@PROJECT_SOURCE_DIR@/doc/doxygen" "@PROJECT_SOURCE_DIR@/include" "@PROJECT_SOURCE_DIR@/src"
RECURSIVE = YES
CLANG_ASSISTED_PARSING = YES
CLANG_DATABASE_PATH = @CMAKE_BINARY_DIR@
GENERATE_HTML = @ARG_HTML@
GENERATE_TREEVIEW = YES
GENERATE_LATEX = @ARG_LATEX@
LATEX_CMD_NAME = xelatex
COMPACT_LATEX = YES
GENERATE_XML = @ARG_XML@
UML_LOOK = YES
TEMPLATE_RELATIONS = YES
CALL_GRAPH = YES
CALLER_GRAPH = YES
INTERACTIVE_SVG = YES

71
lib/doc/Doxygen.cmake Normal file
View File

@ -0,0 +1,71 @@
include_guard(GLOBAL)
# Переменная `CMAKE_CURRENT_FUNCTION_LIST_DIR` позволяет определить
# каталог файла.
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${CMAKE_CURRENT_LIST_DIR})
endif()
function(myx_doc_doxygen NAME)
find_package(Doxygen)
if(DOXYGEN_FOUND)
set(DOXYGEN_FOUND ON CACHE STRING "Doxygen documentation generator enabled" FORCE)
set(DOXYGEN_EXECUTABLE "${DOXYGEN_EXECUTABLE}" CACHE STRING "Path to Doxygen executable")
else()
set(DOXYGEN_FOUND OFF CACHE STRING "Doxygen documentation generator disabled" FORCE)
endif()
set(target "myx-doc-doxygen-${NAME}")
if(NOT DOXYGEN_FOUND)
add_custom_target(${target} VERBATIM COMMENT "Doxygen is not found. Skipping target ${target} build")
return()
endif()
if(TARGET ${target})
myx_message_warning("Target ${target} already defined")
return()
endif()
set(options)
set(oneValueArgs HTML LATEX XML LANGUAGE DOXYFILE_TEMPLATE)
set(multiValueArgs)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT ARG_HTML)
set(ARG_HTML NO)
endif()
if(NOT ARG_LATEX)
set(ARG_LATEX NO)
endif()
if(NOT ARG_XML)
set(ARG_XML YES)
endif()
if(NOT ARG_LANGUAGE)
set(ARG_LANGUAGE "Russian")
endif()
if(NOT ARG_DOXYFILE_TEMPLATE OR NOT EXISTS "${ARG_DOXYFILE_TEMPLATE}")
set(ARG_DOXYFILE_TEMPLATE "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/Doxyfile.in")
endif()
if(NOT DOXYGEN_PROJECT_NAME)
set(DOXYGEN_PROJECT_NAME ${PROJECT_NAME})
endif()
set(work_dir ${PROJECT_BINARY_DIR}/doc/doxygen)
configure_file(${ARG_DOXYFILE_TEMPLATE} ${work_dir}/Doxyfile @ONLY)
add_custom_target(${target}
VERBATIM
WORKING_DIRECTORY ${work_dir}
COMMAND ${DOXYGEN_EXECUTABLE} ${work_dir}/Doxyfile
COMMENT "Generating API documentation with Doxygen")
if(ARG_HTML)
install(DIRECTORY ${CMAKE_BINARY_DIR}/doc/doxygen/html/
COMPONENT doc OPTIONAL
DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/doxygen)
endif()
if(NOT TARGET myx-doc-doxygen)
add_custom_target(myx-doc-doxygen)
endif()
add_dependencies(myx-doc-doxygen ${target})
endfunction()