summaryrefslogtreecommitdiffstats
path: root/docs/CMakeLists.txt
blob: a03333ebb31cf4743e6bdb76d549212c7b156f14 (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
find_package(Sphinx REQUIRED)

if(SPHINX_FOUND)
    if(NOT DEFINED SPHINX_THEME)
        set(SPHINX_THEME default)
    endif()

    if(NOT DEFINED SPHINX_THEME_DIR)
        set(SPHINX_THEME_DIR)
    endif()

    # configured documentation tools and intermediate build results
    set(BINARY_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/_build")

    # Sphinx cache with pickled ReST documents
    set(SPHINX_CACHE_DIR "${CMAKE_CURRENT_BINARY_DIR}/_doctrees")

    # HTML output directory
    set(SPHINX_HTML_DIR "${CMAKE_CURRENT_BINARY_DIR}/../build-root/html")

    configure_file(
            "${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in"
            "${BINARY_BUILD_DIR}/conf.py"
            @ONLY)

    add_custom_target(docs
            ${SPHINX_EXECUTABLE}
            -q -b html
            -c "${BINARY_BUILD_DIR}"
            -d "${SPHINX_CACHE_DIR}"
            "${CMAKE_CURRENT_SOURCE_DIR}"
            "${SPHINX_HTML_DIR}"
            COMMENT "Building HTML documentation with Sphinx")
endif()