generated from cpp-best-practices/cmake_template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDoxygen.cmake
54 lines (48 loc) · 2.32 KB
/
Doxygen.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Enable doxygen doc builds of source
function(cpp_template_enable_doxygen DOXYGEN_THEME)
# If not specified, use the top readme file as the first page
if((NOT DOXYGEN_USE_MDFILE_AS_MAINPAGE) AND EXISTS "${PROJECT_SOURCE_DIR}/README.md")
set(DOXYGEN_USE_MDFILE_AS_MAINPAGE "${PROJECT_SOURCE_DIR}/README.md")
endif()
# set better defaults for doxygen
is_verbose(_is_verbose)
if(NOT ${_is_verbose})
set(DOXYGEN_QUIET YES)
endif()
set(DOXYGEN_CALLER_GRAPH YES)
set(DOXYGEN_CALL_GRAPH YES)
set(DOXYGEN_EXTRACT_ALL YES)
set(DOXYGEN_GENERATE_TREEVIEW YES)
# svg files are much smaller than jpeg and png, and yet they have higher quality
set(DOXYGEN_DOT_IMAGE_FORMAT svg)
set(DOXYGEN_DOT_TRANSPARENT YES)
# If not specified, exclude the vcpkg files and the files CMake downloads under _deps (like project_options)
if(NOT DOXYGEN_EXCLUDE_PATTERNS)
set(DOXYGEN_EXCLUDE_PATTERNS "${CMAKE_CURRENT_BINARY_DIR}/vcpkg_installed/*" "${CMAKE_CURRENT_BINARY_DIR}/_deps/*")
endif()
if("${DOXYGEN_THEME}" STREQUAL "")
set(DOXYGEN_THEME "awesome-sidebar")
endif()
if("${DOXYGEN_THEME}" STREQUAL "awesome" OR "${DOXYGEN_THEME}" STREQUAL "awesome-sidebar")
# use a modern doxygen theme
# https://github.com/jothepro/doxygen-awesome-css v1.6.1
FetchContent_Declare(_doxygen_theme
URL https://github.com/jothepro/doxygen-awesome-css/archive/refs/tags/v1.6.1.zip)
FetchContent_MakeAvailable(_doxygen_theme)
if("${DOXYGEN_THEME}" STREQUAL "awesome" OR "${DOXYGEN_THEME}" STREQUAL "awesome-sidebar")
set(DOXYGEN_HTML_EXTRA_STYLESHEET "${_doxygen_theme_SOURCE_DIR}/doxygen-awesome.css")
endif()
if("${DOXYGEN_THEME}" STREQUAL "awesome-sidebar")
set(DOXYGEN_HTML_EXTRA_STYLESHEET ${DOXYGEN_HTML_EXTRA_STYLESHEET}
"${_doxygen_theme_SOURCE_DIR}/doxygen-awesome-sidebar-only.css")
endif()
else()
# use the original doxygen theme
endif()
# find doxygen and dot if available
find_package(Doxygen REQUIRED OPTIONAL_COMPONENTS dot)
# add doxygen-docs target
message(STATUS "Adding `doxygen-docs` target that builds the documentation.")
doxygen_add_docs(doxygen-docs ALL ${PROJECT_SOURCE_DIR}
COMMENT "Generating documentation - entry file: ${CMAKE_CURRENT_BINARY_DIR}/html/index.html")
endfunction()