|
| 1 | +if(SPHINX_FOUND) |
| 2 | + |
| 3 | + # Sphinx cache with pickled ReST documents |
| 4 | + set(SPHINX_CACHE_DIR "${CMAKE_CURRENT_BINARY_DIR}/_doctrees") |
| 5 | + # HTML output directory |
| 6 | + set(SPHINX_HTML_DIR "${CMAKE_CURRENT_BINARY_DIR}/html") |
| 7 | + set(SPHINX_MAN_DIR "${CMAKE_CURRENT_BINARY_DIR}/man") |
| 8 | + set(SPHINX_PDF_DIR "${CMAKE_CURRENT_BINARY_DIR}/latex") |
| 9 | + set(SPHINX_QCH_DIR "${CMAKE_CURRENT_BINARY_DIR}/qthelp") |
| 10 | + set(SPHINX_HTMLHELP_DIR "${CMAKE_CURRENT_BINARY_DIR}/htmlhelp") |
| 11 | + set(MSHTML_COMPILER wine 'C:\\Program Files\\HTML Help Workshop\\hhc.exe') |
| 12 | + |
| 13 | + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in" conf.py @ONLY) |
| 14 | + add_custom_target(doc ALL DEPENDS doc-html doc-man COMMENT "Building documentation...") |
| 15 | + if(PDFLATEX_FOUND) |
| 16 | + # if this still fails on Debian/Ubuntu, run |
| 17 | + # apt-get install texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended |
| 18 | + add_custom_target(doc-latex ${SPHINX_EXECUTABLE} |
| 19 | + -q -c . -b latex |
| 20 | + -d ${SPHINX_CACHE_DIR} |
| 21 | + ${CMAKE_CURRENT_SOURCE_DIR} |
| 22 | + ${SPHINX_PDF_DIR} ) |
| 23 | + add_custom_target(doc-pdf make -C ${SPHINX_PDF_DIR} all-pdf |
| 24 | + DEPENDS doc-latex ) |
| 25 | + add_dependencies(doc doc-pdf) |
| 26 | + endif(PDFLATEX_FOUND) |
| 27 | + if (EXISTS ${QT_QCOLLECTIONGENERATOR_EXECUTABLE}) |
| 28 | + add_custom_target( doc-qch-sphinx ${SPHINX_EXECUTABLE} |
| 29 | + -q -c . -b qthelp |
| 30 | + -d ${SPHINX_CACHE_DIR} |
| 31 | + ${CMAKE_CURRENT_SOURCE_DIR} |
| 32 | + ${SPHINX_QCH_DIR} ) |
| 33 | + add_custom_target( doc-qch ${QT_QCOLLECTIONGENERATOR_EXECUTABLE} |
| 34 | + ${SPHINX_QCH_DIR}/*.qhcp |
| 35 | + DEPENDS doc-qch-sphinx ) |
| 36 | + add_dependencies(doc doc-qch) |
| 37 | + endif() |
| 38 | + add_custom_target( doc-html ${SPHINX_EXECUTABLE} |
| 39 | + -q -c . -b html |
| 40 | + -d ${SPHINX_CACHE_DIR} |
| 41 | + ${CMAKE_CURRENT_SOURCE_DIR} |
| 42 | + ${SPHINX_HTML_DIR} ) |
| 43 | + add_custom_target( doc-man ${SPHINX_EXECUTABLE} |
| 44 | + -q -c . -b man |
| 45 | + -d ${SPHINX_CACHE_DIR} |
| 46 | + ${CMAKE_CURRENT_SOURCE_DIR} |
| 47 | + ${SPHINX_MAN_DIR} ) |
| 48 | + ## Building CHM files requires HTML Help Workshop. Since it requires wine |
| 49 | + ## with special dependencies, it's impossible to write a cmake check for it. |
| 50 | + ## This is why doc-chm is not a dependency for doc. Instead, run |
| 51 | + ## doc/scripts/htmlhelp.exe to install them and run this target |
| 52 | + ## explicitly. |
| 53 | + add_custom_target( doc-chm-sphinx ${SPHINX_EXECUTABLE} |
| 54 | + -q -c . -b htmlhelp |
| 55 | + -D html_theme=basic |
| 56 | + -d ${SPHINX_CACHE_DIR} |
| 57 | + ${CMAKE_CURRENT_SOURCE_DIR} |
| 58 | + ${SPHINX_HTMLHELP_DIR} ) |
| 59 | + add_custom_target( doc-chm pushd ${SPHINX_HTMLHELP_DIR}; ${MSHTML_COMPILER} *.hhp; popd |
| 60 | + DEPENDS doc-chm-sphinx ) |
| 61 | +endif(SPHINX_FOUND) |
0 commit comments