CMakeLists.txt 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. find_package(Sphinx REQUIRED)
  2. make_directory(${PROJECT_BINARY_DIR}/doc_src)
  3. file(GLOB DOC_SRC "${PROJECT_SOURCE_DIR}/doc/*")
  4. file(COPY ${DOC_SRC} DESTINATION ${PROJECT_BINARY_DIR}/doc_src)
  5. function(generate_rst in out)
  6. add_custom_command(OUTPUT ${out}
  7. DEPENDS ${PROJECT_SOURCE_DIR}/tools/c2rst.py ${in}
  8. PRE_BUILD
  9. COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/c2rst.py ${in} ${out})
  10. endfunction()
  11. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_types.h ${PROJECT_BINARY_DIR}/doc_src/types.rst)
  12. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_constants.h ${PROJECT_BINARY_DIR}/doc_src/constants.rst)
  13. generate_rst(${PROJECT_BINARY_DIR}/src_generated/ua_types_generated.h ${PROJECT_BINARY_DIR}/doc_src/types_generated.rst)
  14. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_server.h ${PROJECT_BINARY_DIR}/doc_src/server.rst)
  15. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_client.h ${PROJECT_BINARY_DIR}/doc_src/client.rst)
  16. generate_rst(${PROJECT_SOURCE_DIR}/src/server/ua_services.h ${PROJECT_BINARY_DIR}/doc_src/services.rst)
  17. generate_rst(${PROJECT_SOURCE_DIR}/src/server/ua_nodestore.h ${PROJECT_BINARY_DIR}/doc_src/nodestore.rst)
  18. add_custom_target(doc_latex ${SPHINX_EXECUTABLE}
  19. -b latex -c "${PROJECT_BINARY_DIR}/doc_src" "${PROJECT_BINARY_DIR}/doc_src" "${PROJECT_BINARY_DIR}/doc_latex"
  20. DEPENDS ${PROJECT_BINARY_DIR}/doc_src/types.rst
  21. DEPENDS ${PROJECT_BINARY_DIR}/doc_src/constants.rst
  22. DEPENDS ${PROJECT_BINARY_DIR}/doc_src/types_generated.rst
  23. DEPENDS ${PROJECT_BINARY_DIR}/doc_src/server.rst
  24. DEPENDS ${PROJECT_BINARY_DIR}/doc_src/client.rst
  25. DEPENDS ${PROJECT_BINARY_DIR}/doc_src/services.rst
  26. DEPENDS ${PROJECT_BINARY_DIR}/doc_src/nodestore.rst
  27. COMMENT "Building LaTeX sources for documentation with Sphinx")
  28. add_dependencies(doc_latex open62541)
  29. add_custom_target(doc ${SPHINX_EXECUTABLE}
  30. -b html -c "${PROJECT_BINARY_DIR}/doc_src" "${PROJECT_BINARY_DIR}/doc_src" "${PROJECT_BINARY_DIR}/doc"
  31. COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_BINARY_DIR}/doc_src/open62541_html.png" "${PROJECT_BINARY_DIR}/doc/_static/"
  32. DEPENDS ${PROJECT_BINARY_DIR}/doc_src/types.rst
  33. DEPENDS ${PROJECT_BINARY_DIR}/doc_src/constants.rst
  34. DEPENDS ${PROJECT_BINARY_DIR}/doc_src/types_generated.rst
  35. DEPENDS ${PROJECT_BINARY_DIR}/doc_src/server.rst
  36. DEPENDS ${PROJECT_BINARY_DIR}/doc_src/client.rst
  37. DEPENDS ${PROJECT_BINARY_DIR}/doc_src/services.rst
  38. DEPENDS ${PROJECT_BINARY_DIR}/doc_src/nodestore.rst
  39. COMMENT "Building HTML documentation with Sphinx")
  40. add_dependencies(doc open62541)