| 1 |
cmake_minimum_required(VERSION 3.17.0 FATAL_ERROR) |
| 2 |
|
| 3 |
if (NOT BASIC_PROJECT_CONFIG_DONE) |
| 4 |
message(FATAL_ERROR "Before including the Doxygen module, the BasicConfig module must be included.") |
| 5 |
endif () |
| 6 |
|
| 7 |
option(NO_DOXYGEN "whether creation of Doxygen targets is disabled (enabled by default)" OFF) |
| 8 |
if (NO_DOXYGEN) |
| 9 |
return() |
| 10 |
endif () |
| 11 |
|
| 12 |
# find doxygen.h template |
| 13 |
include(TemplateFinder) |
| 14 |
find_template_file("doxygen" CPP_UTILITIES DOXYGEN_TEMPLATE_FILE) |
| 15 |
|
| 16 |
# find executables |
| 17 |
find_program(DOXYGEN_BIN doxygen) |
| 18 |
find_program(PERL_BIN perl) |
| 19 |
find_program(DIA_BIN dia) |
| 20 |
if (DIA_BIN) |
| 21 |
set(HAVE_DIA "YES") |
| 22 |
else () |
| 23 |
set(HAVE_DIA "NO") |
| 24 |
endif () |
| 25 |
find_program(DOT_BIN dot) |
| 26 |
if (DOT_BIN) |
| 27 |
set(HAVE_DOT "YES") |
| 28 |
else () |
| 29 |
set(HAVE_DOT "NO") |
| 30 |
endif () |
| 31 |
if (NOT DOXYGEN_BIN) |
| 32 |
message(WARNING "Doxygen not found, unable to add target for generating API documentation for ${META_TARGET_NAME}") |
| 33 |
return() |
| 34 |
endif () |
| 35 |
|
| 36 |
# load cached configuration and other variables |
| 37 |
set(DOXY_LANGUAGE |
| 38 |
"English" |
| 39 |
CACHE STRING "specifies the language of the API documentation generated with Doxygen") |
| 40 |
set(DOXY_CUSTOM_CONFIG |
| 41 |
"" |
| 42 |
CACHE STRING "specifies extra options for Doxygen") |
| 43 |
set(DOXY_NUMBER "${META_APP_VERSION}") |
| 44 |
set(DOXY_INPUT_FILES |
| 45 |
${HEADER_FILES} |
| 46 |
${SRC_FILES} |
| 47 |
${TEST_HEADER_FILES} |
| 48 |
${TEST_SRC_FILES} |
| 49 |
${WIDGETS_HEADER_FILES} |
| 50 |
${WIDGETS_SRC_FILES} |
| 51 |
${QML_HEADER_FILES} |
| 52 |
${QML_SRC_FILES} |
| 53 |
${EXCLUDED_FILES} |
| 54 |
${DOC_FILES}) |
| 55 |
set(DOXY_PATH_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/") |
| 56 |
list(GET DOC_FILES 0 DOXY_MAIN_PAGE_FILE) |
| 57 |
set(DOXY_MAIN_PAGE_FILE "${DOXY_PATH_PREFIX}${DOXY_MAIN_PAGE_FILE}") |
| 58 |
|
| 59 |
# convert DOXY_INPUT_FILES to whitespace-separated list |
| 60 |
include(ListToString) |
| 61 |
list_to_string(" " "\"${DOXY_PATH_PREFIX}" "\"" "${DOXY_INPUT_FILES}" DOXY_INPUT_FILES_WHITESPACE_SEPARATED) |
| 62 |
|
| 63 |
# generate Doxygen configuration |
| 64 |
configure_file("${DOXYGEN_TEMPLATE_FILE}" "${CMAKE_CURRENT_BINARY_DIR}/doxygen.config") |
| 65 |
|
| 66 |
# add target for generating API documentation |
| 67 |
add_custom_target("${META_TARGET_NAME}_apidoc" COMMAND "${DOXYGEN_BIN}" "${CMAKE_CURRENT_BINARY_DIR}/doxygen.config") |
| 68 |
if (NOT TARGET apidoc) |
| 69 |
add_custom_target(apidoc) |
| 70 |
endif () |
| 71 |
add_dependencies(apidoc "${META_TARGET_NAME}_apidoc") |
| 72 |
|
| 73 |
# add install target for API documentation |
| 74 |
if (NOT META_NO_INSTALL_TARGETS AND ENABLE_INSTALL_TARGETS) |
| 75 |
install( |
| 76 |
DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/api-doc" |
| 77 |
DESTINATION "${META_DATA_DIR}" |
| 78 |
COMPONENT api-doc |
| 79 |
OPTIONAL) |
| 80 |
if (NOT TARGET install-api-doc) |
| 81 |
add_custom_target(install-api-doc COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=api-doc -P |
| 82 |
"${CMAKE_BINARY_DIR}/cmake_install.cmake") |
| 83 |
endif () |
| 84 |
endif () |
| 85 |
|
| 86 |
message(STATUS "Added target for building API documentation for ${META_TARGET_NAME} with Doxygen") |