76 lines
2.2 KiB
CMake
76 lines
2.2 KiB
CMake
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
|
|
set(MYX_CMAKE_LIB_DOC_DIR_BACKPORT "${CMAKE_CURRENT_LIST_DIR}")
|
|
endif()
|
|
|
|
function(myx_doc_doxygen TARGET_NAME)
|
|
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
|
|
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_DOC_DIR_BACKPORT})
|
|
endif()
|
|
|
|
if(NOT ${PROJECT_BINARY_DIR} STREQUAL ${CMAKE_BINARY_DIR})
|
|
return()
|
|
endif()
|
|
|
|
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-${TARGET_NAME})
|
|
if(TARGET ${target})
|
|
myx_message_warning("Target ${target} already defined")
|
|
return()
|
|
endif()
|
|
|
|
if(NOT DOXYGEN_FOUND)
|
|
add_custom_target(${target} VERBATIM COMMENT "Doxygen is not found. Skipping target ${target} build")
|
|
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()
|