|
| 1 | +# Documentation build configuration for RAWtoACES |
| 2 | +# |
| 3 | +# This file provides CMake targets for building documentation locally. |
| 4 | +# For Read the Docs builds, the documentation is built directly using |
| 5 | +# Sphinx and Doxygen without CMake. |
| 6 | + |
| 7 | +find_package(Doxygen) |
| 8 | +find_program(SPHINX_EXECUTABLE sphinx-build) |
| 9 | + |
| 10 | +if(DOXYGEN_FOUND AND SPHINX_EXECUTABLE) |
| 11 | + message(STATUS "Documentation tools found - enabling 'docs' target") |
| 12 | + |
| 13 | + # Configure Doxyfile with project paths |
| 14 | + configure_file( |
| 15 | + ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in |
| 16 | + ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile |
| 17 | + @ONLY |
| 18 | + ) |
| 19 | + |
| 20 | + # Doxygen target - generates XML for Breathe |
| 21 | + add_custom_target(doxygen |
| 22 | + COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile |
| 23 | + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
| 24 | + COMMENT "Generating API documentation with Doxygen" |
| 25 | + VERBATIM |
| 26 | + ) |
| 27 | + |
| 28 | + # Sphinx target - generates HTML documentation |
| 29 | + add_custom_target(sphinx |
| 30 | + COMMAND ${SPHINX_EXECUTABLE} |
| 31 | + -b html |
| 32 | + -c ${CMAKE_CURRENT_SOURCE_DIR} |
| 33 | + -D breathe_projects.rawtoaces=${CMAKE_BINARY_DIR}/docs/doxygen/xml |
| 34 | + ${CMAKE_CURRENT_SOURCE_DIR} |
| 35 | + ${CMAKE_CURRENT_BINARY_DIR}/html |
| 36 | + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
| 37 | + COMMENT "Generating HTML documentation with Sphinx" |
| 38 | + DEPENDS doxygen |
| 39 | + VERBATIM |
| 40 | + ) |
| 41 | + |
| 42 | + # Main docs target |
| 43 | + add_custom_target(docs |
| 44 | + DEPENDS sphinx |
| 45 | + COMMENT "Building documentation" |
| 46 | + ) |
| 47 | + |
| 48 | + # Install documentation |
| 49 | + install( |
| 50 | + DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/ |
| 51 | + DESTINATION share/doc/rawtoaces |
| 52 | + OPTIONAL |
| 53 | + COMPONENT documentation |
| 54 | + ) |
| 55 | + |
| 56 | +else() |
| 57 | + if(NOT DOXYGEN_FOUND) |
| 58 | + message(STATUS "Doxygen not found - documentation target disabled") |
| 59 | + endif() |
| 60 | + if(NOT SPHINX_EXECUTABLE) |
| 61 | + message(STATUS "Sphinx not found - documentation target disabled") |
| 62 | + endif() |
| 63 | +endif() |
0 commit comments