cpp-utilities/cmake/modules/Doxygen.cmake

84 lines
2.8 KiB
CMake
Raw Normal View History

2019-02-06 17:30:52 +01:00
if (NOT BASIC_PROJECT_CONFIG_DONE)
2017-02-11 02:30:46 +01:00
message(FATAL_ERROR "Before including the Doxygen module, the BasicConfig module must be included.")
2019-02-06 17:30:52 +01:00
endif ()
2017-02-11 02:30:46 +01:00
2016-09-29 20:28:02 +02:00
option(NO_DOXYGEN "whether creation of Doxygen targets is disabled (enabled by default)" OFF)
2019-02-06 17:30:52 +01:00
if (NO_DOXYGEN)
2018-02-21 23:00:32 +01:00
return()
2019-02-06 17:30:52 +01:00
endif ()
2016-09-29 20:28:02 +02:00
2018-02-21 23:00:32 +01:00
# find doxygen.h template
include(TemplateFinder)
find_template_file("doxygen" CPP_UTILITIES DOXYGEN_TEMPLATE_FILE)
2016-09-29 20:28:02 +02:00
2018-02-21 23:00:32 +01:00
# find executables
find_program(DOXYGEN_BIN doxygen)
find_program(PERL_BIN perl)
find_program(DIA_BIN dia)
2019-02-06 17:30:52 +01:00
if (DIA_BIN)
2018-02-21 23:00:32 +01:00
set(HAVE_DIA "YES")
2019-02-06 17:30:52 +01:00
else ()
2018-02-21 23:00:32 +01:00
set(HAVE_DIA "NO")
2019-02-06 17:30:52 +01:00
endif ()
2018-02-21 23:00:32 +01:00
find_program(DOT_BIN dot)
2019-02-06 17:30:52 +01:00
if (DOT_BIN)
2018-02-21 23:00:32 +01:00
set(HAVE_DOT "YES")
2019-02-06 17:30:52 +01:00
else ()
2018-02-21 23:00:32 +01:00
set(HAVE_DOT "NO")
2019-02-06 17:30:52 +01:00
endif ()
if (NOT DOXYGEN_BIN)
2019-05-04 20:57:56 +02:00
message(WARNING "Doxygen not found, unable to add target for generating API documentation for ${META_TARGET_NAME}")
2018-02-21 23:00:32 +01:00
return()
2019-02-06 17:30:52 +01:00
endif ()
2016-09-29 20:28:02 +02:00
2018-02-21 23:00:32 +01:00
# load cached configuration and other variables
set(DOXY_LANGUAGE "English" CACHE STRING "specifies the language of the API documentation generated with Doxygen")
set(DOXY_CUSTOM_CONFIG "" CACHE STRING "specifies extra options for Doxygen")
set(DOXY_NUMBER "${META_APP_VERSION}")
set(DOXY_INPUT_FILES
2019-02-06 17:30:52 +01:00
${HEADER_FILES}
${SRC_FILES}
${TEST_HEADER_FILES}
${TEST_SRC_FILES}
${WIDGETS_HEADER_FILES}
${WIDGETS_SRC_FILES}
${QML_HEADER_FILES}
${QML_SRC_FILES}
${EXCLUDED_FILES}
${DOC_FILES})
2018-02-21 23:00:32 +01:00
set(DOXY_PATH_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/")
list(GET DOC_FILES 0 DOXY_MAIN_PAGE_FILE)
set(DOXY_MAIN_PAGE_FILE "${DOXY_PATH_PREFIX}${DOXY_MAIN_PAGE_FILE}")
2016-09-29 20:28:02 +02:00
2018-02-21 23:00:32 +01:00
# convert DOXY_INPUT_FILES to whitespace-separated list
include(ListToString)
list_to_string(" "
"\"${DOXY_PATH_PREFIX}"
"\""
"${DOXY_INPUT_FILES}"
DOXY_INPUT_FILES_WHITESPACE_SEPARATED)
2016-09-29 20:28:02 +02:00
2018-02-21 23:00:32 +01:00
# generate Doxygen configuration
2019-02-06 17:30:52 +01:00
configure_file("${DOXYGEN_TEMPLATE_FILE}" "${CMAKE_CURRENT_BINARY_DIR}/doxygen.config")
2018-02-21 23:00:32 +01:00
# add target for generating API documentation
2019-05-04 20:57:56 +02:00
add_custom_target("${META_TARGET_NAME}_apidoc" COMMAND "${DOXYGEN_BIN}" "${CMAKE_CURRENT_BINARY_DIR}/doxygen.config")
2019-02-06 17:30:52 +01:00
if (NOT TARGET apidoc)
2018-02-21 23:00:32 +01:00
add_custom_target(apidoc)
2019-02-06 17:30:52 +01:00
endif ()
2019-04-22 22:19:08 +02:00
add_dependencies(apidoc "${META_TARGET_NAME}_apidoc")
2016-09-29 20:28:02 +02:00
2018-02-21 23:00:32 +01:00
# add install target for API documentation
2019-02-06 17:30:52 +01:00
if (NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS)
2019-05-04 20:57:56 +02:00
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/api-doc" DESTINATION "${META_DATA_DIR}" COMPONENT api-doc OPTIONAL)
2019-02-06 17:30:52 +01:00
if (NOT TARGET install-api-doc)
2018-02-21 23:00:32 +01:00
add_custom_target(install-api-doc
COMMAND "${CMAKE_COMMAND}"
2019-08-06 00:02:38 +02:00
-DCMAKE_INSTALL_COMPONENT=api-doc
-P
2019-02-06 17:30:52 +01:00
"${CMAKE_BINARY_DIR}/cmake_install.cmake")
endif ()
endif ()
2018-02-21 23:00:32 +01:00
2019-05-04 20:57:56 +02:00
message(STATUS "Generating target for generating API documentation for ${META_TARGET_NAME} with Doxygen")