From 33a6c7c7180b43f8f209a7b62cd47e882eb9c7f6 Mon Sep 17 00:00:00 2001 From: Andrey Astafyev Date: Tue, 4 Oct 2022 17:24:08 +0300 Subject: [PATCH] Doxygen --- MyxCMakeConfig.cmake | 1 + lib/doc/Doxyfile.in | 31 +++++++++++++++++++ lib/doc/Doxygen.cmake | 71 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 lib/doc/Doxyfile.in create mode 100644 lib/doc/Doxygen.cmake diff --git a/MyxCMakeConfig.cmake b/MyxCMakeConfig.cmake index b3378fe..b6dc426 100644 --- a/MyxCMakeConfig.cmake +++ b/MyxCMakeConfig.cmake @@ -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) diff --git a/lib/doc/Doxyfile.in b/lib/doc/Doxyfile.in new file mode 100644 index 0000000..c8923f8 --- /dev/null +++ b/lib/doc/Doxyfile.in @@ -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 diff --git a/lib/doc/Doxygen.cmake b/lib/doc/Doxygen.cmake new file mode 100644 index 0000000..794335e --- /dev/null +++ b/lib/doc/Doxygen.cmake @@ -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()