myx-cmake/MyxCMake/modules/MyxCMakeDocDoxygen.cmake

100 lines
3.1 KiB
CMake
Raw Normal View History

2022-05-06 09:49:46 +00:00
include_guard(GLOBAL)
function(myx_cmake_doc_doxygen)
set(DOXYGEN_FOUND AUTO CACHE STRING "Enable Doxygen documentation generator")
set_property(CACHE DOXYGEN_FOUND PROPERTY STRINGS ON OFF AUTO)
find_package(Doxygen)
if(DOXYGEN_FOUND)
set(DOXYGEN_FOUND ON CACHE STRING "Doxygen documentation generator enabled" FORCE)
else()
set(DOXYGEN_FOUND OFF CACHE STRING "Doxygen documentation generator disabled" FORCE)
endif()
set(_target "myx-cmake-doc-doxygen-${CMAKE_PROJECT_NAME}")
if(NOT DOXYGEN_FOUND)
message(STATUS "MyxCMake:")
add_custom_target(${_target} VERBATIM COMMENT " Doxygen is not found. Skipping target ${_target} build")
return()
endif()
if(NOT TARGET ${_target})
set(options)
2022-05-06 09:49:46 +00:00
set(oneValueArgs SQLITE LATEX HTML LANGUAGE)
set(multiValueArgs)
cmake_parse_arguments(_arg "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set(GENERATE_XML YES)
set(GENERATE_HTML NO)
set(GENERATE_LATEX NO)
2022-05-06 09:49:46 +00:00
set(DOXYGEN_OUTPUT_LANGUAGE Russian)
if(_arg_HTML)
set(GENERATE_HTML YES)
endif()
if(_arg_LATEX)
set(GENERATE_LATEX YES)
endif()
2022-05-06 09:49:46 +00:00
if(_arg_LANGUAGE)
set(DOXYGEN_OUTPUT_LANGUAGE ${_arg_LANGUAGE})
endif()
2022-05-06 09:49:46 +00:00
set(_myx_cmake_doxygen_in
"
PROJECT_NAME = \"${DOXYGEN_PROJECT_TITLE}\"
OUTPUT_DIRECTORY = \"${DOXYGEN_OUTPUT_DIRECTORY}\"
OUTPUT_LANGUAGE = \"${DOXYGEN_OUTPUT_LANGUAGE}\"
STRIP_FROM_PATH = \"${CMAKE_HOME_DIRECTORY}/src}\"
STRIP_FROM_INC_PATH = \"${CMAKE_HOME_DIRECTORY}/src}\"
EXTRACT_ALL = YES
EXTRACT_PRIVATE = YES
EXTRACT_STATIC = YES
EXTRACT_LOCAL_METHODS = YES
INPUT = \"${CMAKE_HOME_DIRECTORY}/src\" \"${CMAKE_HOME_DIRECTORY}/doc/doxygen\"
RECURSIVE = YES
CLANG_ASSISTED_PARSING = YES
CLANG_DATABASE_PATH = \"${CMAKE_BINARY_DIR}\"
GENERATE_HTML = ${GENERATE_HTML}
GENERATE_TREEVIEW = YES
GENERATE_LATEX = ${GENERATE_LATEX}
LATEX_CMD_NAME = xelatex
COMPACT_LATEX = YES
GENERATE_XML = YES
UML_LOOK = YES
TEMPLATE_RELATIONS = YES
CALL_GRAPH = YES
CALLER_GRAPH = YES
INTERACTIVE_SVG = YES
")
set(_myx_cmake_doxygen_in_path ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/Doxygen.in)
file(WRITE ${_myx_cmake_doxygen_in_path} ${_myx_cmake_doxygen_in})
set(work_dir ${CMAKE_BINARY_DIR}/doc/doxygen)
2022-05-06 09:49:46 +00:00
configure_file(${_myx_cmake_doxygen_in_path} ${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-cmake-doc-doxygen)
add_custom_target(myx-cmake-doc-doxygen)
endif()
add_dependencies(myx-cmake-doc-doxygen ${_target})
else()
message(STATUS "MyxCMake: target ${_target} is already defined.")
endif()
endfunction()