| 1 |
# Use FindDoxygen.cmake to generate documentation. |
| 2 |
|
| 3 |
option(DOXYGEN_GENERATE_HTML "Generate HTML" ON) |
| 4 |
option(DOXYGEN_GENERATE_MAN "Generate man pages" OFF) |
| 5 |
option(DOXYGEN_MAN_LINKS "Generate man links" ON) |
| 6 |
option(DOXYGEN_GENERATE_LATEX "Generate LaTeX" OFF) |
| 7 |
|
| 8 |
# If the case-insensitive value of the cmake option is one of |
| 9 |
# "off, no, false" or 0, it is equal to false, otherwise true. |
| 10 |
# And the values of the doxygen config does not exactly match it. |
| 11 |
# So we need to convert the cmake option to a doxygen config. |
| 12 |
macro(_convert_to_dx_cfg CMK_OPTION) |
| 13 |
if (${CMK_OPTION}) |
| 14 |
set(${CMK_OPTION} YES) |
| 15 |
else() |
| 16 |
set(${CMK_OPTION} NO) |
| 17 |
endif() |
| 18 |
endmacro() |
| 19 |
|
| 20 |
macro(UseDoxygen) |
| 21 |
if (${CMAKE_VERSION} VERSION_LESS "3.9") |
| 22 |
# Old versions of cmake have poor support for Doxygen generation. |
| 23 |
message(FATAL_ERROR "Doxygen generation only enabled for cmake 3.9 and higher") |
| 24 |
else() |
| 25 |
find_package(Doxygen) |
| 26 |
if (DOXYGEN_FOUND) |
| 27 |
set(DOXYGEN_PROJECT_NAME ${PROJECT_NAME}) |
| 28 |
set(DOXYGEN_PROJECT_NUMBER ${EVENT_PACKAGE_VERSION}) |
| 29 |
set(DOXYGEN_PROJECT_BRIEF "Event notification library") |
| 30 |
set(DOXYGEN_OUTPUT_DIRECTORY doxygen) |
| 31 |
set(DOXYGEN_STRIP_FROM_PATH include) |
| 32 |
set(DOXYGEN_JAVADOC_AUTOBRIEF YES) |
| 33 |
set(DOXYGEN_OPTIMIZE_OUTPUT_FOR_C YES) |
| 34 |
set(DOXYGEN_SORT_BRIEF_DOCS YES) |
| 35 |
set(DOXYGEN_RECURSIVE NO) |
| 36 |
|
| 37 |
_convert_to_dx_cfg(DOXYGEN_GENERATE_HTML) |
| 38 |
_convert_to_dx_cfg(DOXYGEN_GENERATE_MAN) |
| 39 |
_convert_to_dx_cfg(DOXYGEN_MAN_LINKS) |
| 40 |
_convert_to_dx_cfg(DOXYGEN_GENERATE_LATEX) |
| 41 |
|
| 42 |
set(DOXYGEN_LATEX_CMD_NAME latex) |
| 43 |
set(DOXYGEN_PAPER_TYPE a4wide) |
| 44 |
set(DOXYGEN_PDF_HYPERLINKS NO) |
| 45 |
|
| 46 |
set(DOXYGEN_GENERATE_RTF NO) |
| 47 |
set(DOXYGEN_GENERATE_XML NO) |
| 48 |
set(DOXYGEN_GENERATE_CHI NO) |
| 49 |
|
| 50 |
set(DOXYGEN_PREDEFINED TAILQ_ENTRY |
| 51 |
RB_ENTRY |
| 52 |
EVENT_DEFINED_TQENTRY_ |
| 53 |
EVENT_IN_DOXYGEN_ |
| 54 |
) |
| 55 |
|
| 56 |
set(DOX_INPUT include/event2/buffer.h |
| 57 |
include/event2/buffer_compat.h |
| 58 |
include/event2/bufferevent.h |
| 59 |
include/event2/bufferevent_compat.h |
| 60 |
include/event2/bufferevent_ssl.h |
| 61 |
include/event2/dns.h |
| 62 |
include/event2/dns_compat.h |
| 63 |
include/event2/event.h |
| 64 |
include/event2/event_compat.h |
| 65 |
include/event2/http.h |
| 66 |
include/event2/http_compat.h |
| 67 |
include/event2/listener.h |
| 68 |
include/event2/rpc.h |
| 69 |
include/event2/rpc_compat.h |
| 70 |
include/event2/tag.h |
| 71 |
include/event2/tag_compat.h |
| 72 |
include/event2/thread.h |
| 73 |
include/event2/util.h |
| 74 |
) |
| 75 |
# Add 'doxygen' target |
| 76 |
doxygen_add_docs(doxygen |
| 77 |
${DOX_INPUT} |
| 78 |
ALL |
| 79 |
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} |
| 80 |
COMMENT "Generating doxygen documentation for ${PROJECT_NAME}..." |
| 81 |
) |
| 82 |
|
| 83 |
# Use 'make clean' to remove the generated directory |
| 84 |
set_property(DIRECTORY |
| 85 |
PROPERTY ADDITIONAL_MAKE_CLEAN_FILES |
| 86 |
"${PROJECT_BINARY_DIR}/${DOXYGEN_OUTPUT_DIRECTORY}" |
| 87 |
) |
| 88 |
|
| 89 |
# Install html into <prefix>/share/doc/<project> |
| 90 |
if ("${DOXYGEN_GENERATE_HTML}" STREQUAL "YES") |
| 91 |
install(DIRECTORY |
| 92 |
${PROJECT_BINARY_DIR}/${DOXYGEN_OUTPUT_DIRECTORY}/html |
| 93 |
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/${PROJECT_NAME} |
| 94 |
COMPONENT doc |
| 95 |
) |
| 96 |
endif() |
| 97 |
|
| 98 |
# Install manual into <prefix>/share/man/man3 |
| 99 |
if ("${DOXYGEN_GENERATE_MAN}" STREQUAL "YES") |
| 100 |
install(DIRECTORY |
| 101 |
${PROJECT_BINARY_DIR}/${DOXYGEN_OUTPUT_DIRECTORY}/man/man3 |
| 102 |
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man |
| 103 |
COMPONENT doc |
| 104 |
) |
| 105 |
endif() |
| 106 |
|
| 107 |
else(DOXYGEN_FOUND) |
| 108 |
message(FATAL_ERROR "Doxygen command not found, set EVENT__DOXYGEN to disable") |
| 109 |
endif (DOXYGEN_FOUND) |
| 110 |
endif() |
| 111 |
endmacro() |