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