CMakeLists.txt 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. if(SPHINX_FOUND)
  2. # Sphinx cache with pickled ReST documents
  3. set(SPHINX_CACHE_DIR "${CMAKE_CURRENT_BINARY_DIR}/_doctrees")
  4. # HTML output directory
  5. set(SPHINX_HTML_DIR "${CMAKE_CURRENT_BINARY_DIR}/html")
  6. set(SPHINX_PDF_DIR "${CMAKE_CURRENT_BINARY_DIR}/latex")
  7. set(SPHINX_QCH_DIR "${CMAKE_CURRENT_BINARY_DIR}/qthelp")
  8. set(SPHINX_HTMLHELP_DIR "${CMAKE_CURRENT_BINARY_DIR}/htmlhelp")
  9. set(MSHTML_COMPILER wine 'C:\\Program Files\\HTML Help Workshop\\hhc.exe')
  10. # assets
  11. set(LATEX_LOGO "${CMAKE_CURRENT_SOURCE_DIR}/logo-blue.pdf")
  12. set(APPLICATION_DOC_DIR "${CMAKE_INSTALL_DOCDIR}/${PACKAGE}")
  13. install(DIRECTORY ${SPHINX_HTML_DIR} DESTINATION ${APPLICATION_DOC_DIR} OPTIONAL)
  14. install(DIRECTORY ${SPHINX_PDF_DIR} DESTINATION ${APPLICATION_DOC_DIR} OPTIONAL)
  15. install(DIRECTORY ${SPHINX_QCH_DIR} DESTINATION ${APPLICATION_DOC_DIR} OPTIONAL)
  16. configure_file("${CMAKE_CURRENT_SOURCE_DIR}/conf.py" conf.py COPYONLY)
  17. if(WITH_DOC)
  18. add_custom_target(doc ALL DEPENDS doc-html COMMENT "Building documentation...")
  19. else(WITH_DOC)
  20. add_custom_target(doc DEPENDS doc-html COMMENT "Building documentation...")
  21. endif(WITH_DOC)
  22. if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/ocdoc/_shared_assets")
  23. add_dependencies(doc doc-html-org)
  24. add_dependencies(doc doc-html-com)
  25. endif()
  26. if(PDFLATEX_FOUND)
  27. # if this still fails on Debian/Ubuntu, run
  28. # apt-get install texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended
  29. add_custom_target(doc-latex ${SPHINX_EXECUTABLE}
  30. -q -c . -b latex
  31. -d ${SPHINX_CACHE_DIR}/latex
  32. -D latex_logo=${LATEX_LOGO}
  33. ${CMAKE_CURRENT_SOURCE_DIR}
  34. ${SPHINX_PDF_DIR} )
  35. set(MAKE "make" CACHE FILEPATH "make to be used for documentation generation if not using make as generator anyway")
  36. if(CMAKE_GENERATOR MATCHES "Makefiles")
  37. set(MAKE "$(MAKE)")
  38. endif()
  39. add_custom_target(doc-pdf ${MAKE} -C ${SPHINX_PDF_DIR} all-pdf
  40. DEPENDS doc-latex )
  41. add_dependencies(doc doc-pdf)
  42. endif(PDFLATEX_FOUND)
  43. if (EXISTS ${QT_QCOLLECTIONGENERATOR_EXECUTABLE})
  44. add_custom_target( doc-qch-sphinx ${SPHINX_EXECUTABLE}
  45. -q -c . -b qthelp
  46. -d ${SPHINX_CACHE_DIR}/qthelp
  47. ${CMAKE_CURRENT_SOURCE_DIR}
  48. ${SPHINX_QCH_DIR} )
  49. add_custom_target( doc-qch ${QT_QCOLLECTIONGENERATOR_EXECUTABLE}
  50. ${SPHINX_QCH_DIR}/*.qhcp
  51. DEPENDS doc-qch-sphinx )
  52. add_dependencies(doc doc-qch)
  53. endif()
  54. add_custom_target( doc-html ${SPHINX_EXECUTABLE}
  55. -q -c . -b html
  56. -d ${SPHINX_CACHE_DIR}/html
  57. ${CMAKE_CURRENT_SOURCE_DIR}
  58. ${SPHINX_HTML_DIR}/unthemed )
  59. add_custom_target( doc-html-org ${SPHINX_EXECUTABLE}
  60. -q -c . -b html
  61. -d ${SPHINX_CACHE_DIR}/html
  62. -D html_theme=owncloud_org
  63. ${CMAKE_CURRENT_SOURCE_DIR}
  64. ${SPHINX_HTML_DIR}/org )
  65. add_custom_target( doc-html-com ${SPHINX_EXECUTABLE}
  66. -q -c . -b html
  67. -d ${SPHINX_CACHE_DIR}/html
  68. -D html_theme=owncloud_com
  69. ${CMAKE_CURRENT_SOURCE_DIR}
  70. ${SPHINX_HTML_DIR}/com )
  71. ## Building CHM files requires HTML Help Workshop. Since it requires wine
  72. ## with special dependencies, it's impossible to write a cmake check for it.
  73. ## This is why doc-chm is not a dependency for doc. Instead, run
  74. ## doc/scripts/htmlhelp.exe to install them and run this target
  75. ## explicitly.
  76. add_custom_target( doc-chm-sphinx ${SPHINX_EXECUTABLE}
  77. -q -c . -b htmlhelp
  78. -D html_theme=basic
  79. -d ${SPHINX_CACHE_DIR}/htmlhelp
  80. ${CMAKE_CURRENT_SOURCE_DIR}
  81. ${SPHINX_HTMLHELP_DIR} )
  82. add_custom_target( doc-chm pushd ${SPHINX_HTMLHELP_DIR}; ${MSHTML_COMPILER} *.hhp; popd
  83. DEPENDS doc-chm-sphinx )
  84. endif(SPHINX_FOUND)