summaryrefslogtreecommitdiffstats
path: root/cmake/docs.cmake
blob: 286d027fb959a8c5a2cf3bc8c774e1e9021aa9a2 (plain)
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
# ---- Dependencies ----

set(extract_timestamps "")
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24")
    set(extract_timestamps DOWNLOAD_EXTRACT_TIMESTAMP YES)
endif ()

include(FetchContent)
FetchContent_Declare(
        mcss URL
        https://github.com/friendlyanon/m.css/releases/download/release-1/mcss.zip
        URL_MD5 00cd2757ebafb9bcba7f5d399b3bec7f
        SOURCE_DIR "${PROJECT_BINARY_DIR}/mcss"
        UPDATE_DISCONNECTED YES
        ${extract_timestamps}
)
FetchContent_MakeAvailable(mcss)

find_package(Python3 3.6 REQUIRED)

# ---- Declare documentation target ----

set(
        DOXYGEN_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/docs"
        CACHE PATH "Path for the generated Doxygen documentation"
)

set(working_dir "${PROJECT_BINARY_DIR}/docs")

foreach (file IN ITEMS Doxyfile conf.py)
    configure_file("docs/${file}.in" "${working_dir}/${file}" @ONLY)
endforeach ()

set(mcss_script "${mcss_SOURCE_DIR}/documentation/doxygen.py")
set(config "${working_dir}/conf.py")

add_custom_target(
        docs
        COMMAND "${CMAKE_COMMAND}" -E remove_directory
        "${DOXYGEN_OUTPUT_DIRECTORY}/html"
        "${DOXYGEN_OUTPUT_DIRECTORY}/xml"
        COMMAND "${Python3_EXECUTABLE}" "${mcss_script}" "${config}"
        COMMENT "Building documentation using Doxygen and m.css"
        WORKING_DIRECTORY "${working_dir}"
        VERBATIM
)