diff options
author | tastytea | 2020-11-13 14:25:22 +0100 |
---|---|---|
committer | tastytea | 2020-11-13 14:25:22 +0100 |
commit | aeb7396961b4afcb716cec498ca40fe918c4eb46 (patch) | |
tree | 9073c89e8a4c15faf7da8153ac3cd64886efb458 | |
parent | f4bd5abd0197fe04a813089ffa00c14ec68f999a (diff) | |
download | mastodonpp-aeb7396961b4afcb716cec498ca40fe918c4eb46.tar mastodonpp-aeb7396961b4afcb716cec498ca40fe918c4eb46.tar.gz mastodonpp-aeb7396961b4afcb716cec498ca40fe918c4eb46.zip |
Generate API documentation with CMake.
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | CMakeLists.txt | 8 | ||||
-rw-r--r-- | Doxyfile | 27 | ||||
-rw-r--r-- | README.adoc | 1 | ||||
-rwxr-xr-x | build_doc.sh | 11 | ||||
-rw-r--r-- | cmake/Doxygen.cmake | 43 |
6 files changed, 52 insertions, 39 deletions
@@ -1,4 +1,3 @@ /build/ -/doc/ /update_doc.sh /examples/example99* diff --git a/CMakeLists.txt b/CMakeLists.txt index e13eedf..5e670c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,7 @@ list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") # Project build options. option(WITH_TESTS "Compile tests." NO) option(WITH_EXAMPLES "Compile examples." NO) +option(WITH_DOC "Generate API documentation." NO) option(WITH_DEB "Prepare for the building of .deb packages." NO) option(WITH_RPM "Prepare for the building of .rpm packages." NO) option(WITH_CLANG-TIDY "Check sourcecode with clang-tidy while compiling." NO) @@ -60,4 +61,11 @@ if(WITH_EXAMPLES) add_subdirectory(examples) endif() +if(WITH_DOC) + include(cmake/Doxygen.cmake) + enable_doxygen( + "${CMAKE_CURRENT_SOURCE_DIR}/include" + "${CMAKE_CURRENT_SOURCE_DIR}/src") +endif() + include(cmake/packages.cmake) diff --git a/Doxyfile b/Doxyfile deleted file mode 100644 index 5484c91..0000000 --- a/Doxyfile +++ /dev/null @@ -1,27 +0,0 @@ -# -*- mode: conf-unix -*- -INPUT = src/ include/ -RECURSIVE = YES -STRIP_FROM_INC_PATH = "include" -EXAMPLE_PATH = examples/ -EXAMPLE_RECURSIVE = YES -GENERATE_HTML = YES -HTML_OUTPUT = doc/html -GENERATE_LATEX = NO -ALLOW_UNICODE_NAMES = YES -BRIEF_MEMBER_DESC = YES -REPEAT_BRIEF = YES -ALWAYS_DETAILED_SEC = YES -INLINE_INHERITED_MEMB = NO -INHERIT_DOCS = YES -SEPARATE_MEMBER_PAGES = NO -TAB_SIZE = 4 -MARKDOWN_SUPPORT = YES -AUTOLINK_SUPPORT = YES -INLINE_SIMPLE_STRUCTS = NO -QUIET = NO -WARNINGS = YES -BUILTIN_STL_SUPPORT = YES -VERBATIM_HEADERS = YES -INLINE_SOURCES = YES -SEARCHENGINE = YES -SHOW_FILES = YES diff --git a/README.adoc b/README.adoc index 506d6c8..9b5b8df 100644 --- a/README.adoc +++ b/README.adoc @@ -151,6 +151,7 @@ cmake --build . -- -j$(nproc --ignore=1) * `-DCMAKE_BUILD_TYPE=Debug` for a debug build. * `-DWITH_TESTS=YES` if you want to compile the tests. * `-DWITH_EXAMPLES=YES` if you want to compile the examples. +* `-DWITH_DOC=YES` if you want to generate the API documentation. * `-DWITH_CLANG-TIDY=YES` to check the sourcecode with link:{uri-clang-tidy}[clang-tidy] while compiling. * One of: diff --git a/build_doc.sh b/build_doc.sh deleted file mode 100755 index 40b1371..0000000 --- a/build_doc.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -project="$(realpath --relative-base=.. .)" -version="$(grep -Eo '[0-9]+.[0-9]+.[0-9]+$' CMakeLists.txt)" - -if [[ -f Doxyfile ]]; then - mkdir -p doc - (doxygen -s -g - && cat Doxyfile && - echo "PROJECT_NAME = ${project}" && - echo "PROJECT_NUMBER = ${version}") | doxygen - -fi diff --git a/cmake/Doxygen.cmake b/cmake/Doxygen.cmake new file mode 100644 index 0000000..ef0c4e7 --- /dev/null +++ b/cmake/Doxygen.cmake @@ -0,0 +1,43 @@ +include(GNUInstallDirs) + +function(enable_doxygen) + find_package(Doxygen REQUIRED dot) + + set(DOXYGEN_RECURSIVE YES) + set(DOXYGEN_STRIP_FROM_INC_PATH "include") + if (WITH_EXAMPLES) + set(DOXYGEN_EXAMPLE_PATH "examples/") + set(DOXYGEN_EXAMPLE_RECURSIVE YES) + endif() + set(DOXYGEN_GENERATE_HTML YES) + set(DOXYGEN_HTML_OUTPUT "doc/html") + set(DOXYGEN_GENERATE_LATEX NO) + set(DOXYGEN_ALLOW_UNICODE_NAMES YES) + set(DOXYGEN_BRIEF_MEMBER_DESC YES) + set(DOXYGEN_REPEAT_BRIEF YES) + set(DOXYGEN_ALWAYS_DETAILED_SEC YES) + set(DOXYGEN_INLINE_INHERITED_MEMB NO) + set(DOXYGEN_INHERIT_DOCS YES) + set(DOXYGEN_SEPARATE_MEMBER_PAGES NO) + set(DOXYGEN_TAB_SIZE 4) + set(DOXYGEN_MARKDOWN_SUPPORT YES) + set(DOXYGEN_AUTOLINK_SUPPORT YES) + set(DOXYGEN_INLINE_SIMPLE_STRUCTS NO) + set(DOXYGEN_QUIET YES) + set(DOXYGEN_WARNINGS YES) + set(DOXYGEN_WARN_IF_UNDOCUMENTED YES) + set(DOXYGEN_BUILTIN_STL_SUPPORT YES) + set(DOXYGEN_VERBATIM_HEADERS YES) + set(DOXYGEN_INLINE_SOURCES YES) + set(DOXYGEN_SEARCHENGINE YES) + set(DOXYGEN_SHOW_FILES YES) + + file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/doc") + + doxygen_add_docs(${PROJECT_NAME}_doxygen "${ARGV}") + # Make sure doxygen is run with every build. + add_custom_target(${PROJECT_NAME}_docs ALL DEPENDS ${PROJECT_NAME}_doxygen) + + install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/html + DESTINATION "${CMAKE_INSTALL_DOCDIR}") +endfunction() |