2022-10-06 12:22:57 +00:00
|
|
|
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
|
|
|
|
set(MYX_CMAKE_LIB_DOC_DIR_BACKPORT "${CMAKE_CURRENT_LIST_DIR}")
|
|
|
|
endif()
|
|
|
|
|
2022-10-20 09:53:06 +00:00
|
|
|
function(myx_doc_doxygen TARGET_NAME)
|
2022-10-06 12:22:57 +00:00
|
|
|
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
|
|
|
|
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_DOC_DIR_BACKPORT})
|
|
|
|
endif()
|
|
|
|
|
2022-10-20 09:53:06 +00:00
|
|
|
if(NOT ${PROJECT_BINARY_DIR} STREQUAL ${CMAKE_BINARY_DIR})
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
2022-10-06 12:22:57 +00:00
|
|
|
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()
|
|
|
|
|
2022-10-20 09:53:06 +00:00
|
|
|
set(target myx-doc-doxygen-${TARGET_NAME})
|
|
|
|
if(TARGET ${target})
|
|
|
|
myx_message_warning("Target ${target} already defined")
|
2022-10-06 12:22:57 +00:00
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
2022-10-20 09:53:06 +00:00
|
|
|
if(NOT DOXYGEN_FOUND)
|
|
|
|
add_custom_target(${target} VERBATIM COMMENT "Doxygen is not found. Skipping target ${target} build")
|
2022-10-06 12:22:57 +00:00
|
|
|
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/
|
2022-10-20 09:53:06 +00:00
|
|
|
COMPONENT DOC OPTIONAL
|
2022-10-06 12:22:57 +00:00
|
|
|
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()
|