include_guard(GLOBAL) 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 "${MYX_CMAKE_LIB_DIR}/doc/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()