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