From 6a70407a95ed5e90df03c20c95f8ad0802d45166 Mon Sep 17 00:00:00 2001 From: Andrea Pappacoda Date: Sat, 1 Oct 2022 18:07:38 +0200 Subject: [PATCH] build: add doc target This patch adds a doc target generating Doxygen documentation similarly to , but with some extra bits: if doxygen-awesome.css is found on the host system, CMake will automatically use it to generate themed documentation. Using `doxygen_add_docs()` requires setting the various Doxygen options in CMakeLists.txt, so there's currently a bit of duplication as the same options are also contained in Doxyfile and Doxyfile-themed. I couldn't remove the two standalone files as they are still required by the doc.yml CI/CD pipeline, as `zydoc` runs Doxygen itself; as a solution, `zydoc` could add support for a `--doxygen-generated ` flag that tells it to use already generated Doxygen documentation instead of generating its own. --- CMakeLists.txt | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 45e6d0d7..c6007891 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -440,6 +440,45 @@ if (ZYDIS_BUILD_TOOLS AND NOT ZYAN_NO_LIBC) endif () endif () +# =============================================================================================== # +# Doxygen documentation # +# =============================================================================================== # +find_package(Doxygen) +if (DOXYGEN_FOUND) + find_file(DOXYGEN_AWESOME_CSS + "doxygen-awesome.css" + PATHS "." ".." "/usr/share" + PATH_SUFFIXES "doxygen-awesome-css" + NO_DEFAULT_PATH + ) + find_file(DOXYGEN_AWESOME_SIDEBAR_ONLY_CSS + "doxygen-awesome-sidebar-only.css" + PATHS "." ".." "/usr/share" + PATH_SUFFIXES "doxygen-awesome-css" + NO_DEFAULT_PATH + ) + + set(DOXYGEN_JAVADOC_AUTOBRIEF YES) + set(DOXYGEN_QT_AUTOBRIEF YES) + set(DOXYGEN_OPTIMIZE_OUTPUT_FOR_C YES) + set(DOXYGEN_TOC_INCLUDE_HEADINGS 0) + set(DOXYGEN_EXTRACT_LOCAL_CLASSES NO) + set(DOXYGEN_HIDE_SCOPE_NAMES YES) + set(DOXYGEN_USE_MDFILE_AS_MAINPAGE "README.md") + set(DOXYGEN_GENERATE_TREEVIEW YES) + set(DOXYGEN_DISABLE_INDEX NO) + set(DOXYGEN_FULL_SIDEBAR NO) + set(DOXYGEN_HTML_EXTRA_STYLESHEET "${DOXYGEN_AWESOME_CSS}" "${DOXYGEN_AWESOME_SIDEBAR_ONLY_CSS}") + + doxygen_add_docs(doc "./include" "./README.md" "./files.dox" ALL) + + install( + DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/html/" + DESTINATION "${CMAKE_INSTALL_DOCDIR}/api" + COMPONENT Documentation + ) +endif() + # =============================================================================================== # # Manpages # # =============================================================================================== #