You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.2 KiB

3 months ago
  1. # This modules defines
  2. # SPHINX_EXECUTABLE
  3. # SPHINX_FOUND
  4. find_program(SPHINX_EXECUTABLE
  5. NAMES sphinx-build sphinx-build2
  6. HINTS $ENV{SPHINX_DIR}
  7. PATHS
  8. /usr/bin
  9. /usr/local/bin
  10. /opt/local/bin
  11. DOC "Sphinx documentation generator"
  12. )
  13. include(FindPackageHandleStandardArgs)
  14. find_package_handle_standard_args(Sphinx DEFAULT_MSG SPHINX_EXECUTABLE)
  15. option( SPHINX_HTML_OUTPUT "Build a single HTML with the whole content." ON )
  16. option( SPHINX_EPUB_OUTPUT "Build HTML pages with additional information for building a documentation collection in epub." OFF )
  17. option( SPHINX_LATEX_OUTPUT "Build LaTeX sources that can be compiled to a PDF document using pdflatex." OFF )
  18. option( SPHINX_MAN_OUTPUT "Build manual pages in groff format for UNIX systems." OFF )
  19. option( SPHINX_TEXT_OUTPUT "Build plain text files." OFF )
  20. mark_as_advanced(
  21. SPHINX_EXECUTABLE
  22. SPHINX_HTML_OUTPUT
  23. SPHINX_EPUB_OUTPUT
  24. SPHINX_LATEX_OUTPUT
  25. SPHINX_MAN_OUTPUT
  26. SPHINX_TEXT_OUTPUT
  27. )
  28. function( Sphinx_add_target target_name builder conf source destination )
  29. add_custom_target( ${target_name} ALL
  30. COMMAND ${SPHINX_EXECUTABLE} -b ${builder}
  31. -c ${conf}
  32. ${source}
  33. ${destination}
  34. COMMENT "Generating sphinx documentation: ${builder}"
  35. )
  36. set_property(
  37. DIRECTORY APPEND PROPERTY
  38. ADDITIONAL_MAKE_CLEAN_FILES
  39. ${destination}
  40. )
  41. endfunction()
  42. # Target dependencies can be optionally listed at the end.
  43. function( Sphinx_add_targets target_base_name conf source base_destination )
  44. if( ${SPHINX_HTML_OUTPUT} )
  45. Sphinx_add_target( ${target_base_name}_html html ${conf} ${source} ${base_destination}/html )
  46. endif()
  47. if( ${SPHINX_EPUB_OUTPUT} )
  48. Sphinx_add_target( ${target_base_name}_epub epub ${conf} ${source} ${base_destination}/epub )
  49. endif()
  50. if( ${SPHINX_LATEX_OUTPUT} )
  51. Sphinx_add_target( ${target_base_name}_latex latex ${conf} ${source} ${base_destination}/latex )
  52. endif()
  53. if( ${SPHINX_MAN_OUTPUT} )
  54. Sphinx_add_target( ${target_base_name}_man man ${conf} ${source} ${base_destination}/man )
  55. endif()
  56. if( ${SPHINX_TEXT_OUTPUT} )
  57. Sphinx_add_target( ${target_base_name}_text text ${conf} ${source} ${base_destination}/text )
  58. endif()
  59. endfunction()