CMakeLists.txt 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. find_package(Sphinx REQUIRED)
  2. find_package(LATEX)
  3. set(DOC_LATEX_DIR ${PROJECT_BINARY_DIR}/doc_latex)
  4. set(DOC_HTML_DIR ${PROJECT_BINARY_DIR}/doc)
  5. set(DOC_SRC_DIR ${PROJECT_BINARY_DIR}/doc_src)
  6. make_directory(${DOC_SRC_DIR})
  7. file(GLOB DOC_SRC "${PROJECT_SOURCE_DIR}/doc/*")
  8. file(COPY ${DOC_SRC} DESTINATION ${DOC_SRC_DIR})
  9. function(generate_rst in out)
  10. add_custom_command(OUTPUT ${out} DEPENDS ${PROJECT_SOURCE_DIR}/tools/c2rst.py ${in}
  11. PRE_BUILD COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/c2rst.py ${in} ${out})
  12. endfunction()
  13. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_types.h ${DOC_SRC_DIR}/types.rst)
  14. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_constants.h ${DOC_SRC_DIR}/constants.rst)
  15. generate_rst(${PROJECT_BINARY_DIR}/src_generated/ua_types_generated.h ${DOC_SRC_DIR}/types_generated.rst)
  16. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_server.h ${DOC_SRC_DIR}/server.rst)
  17. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_client.h ${DOC_SRC_DIR}/client.rst)
  18. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_client_highlevel.h ${DOC_SRC_DIR}/client_highlevel.rst)
  19. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_log.h ${DOC_SRC_DIR}/log.rst)
  20. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_connection.h ${DOC_SRC_DIR}/connection.rst)
  21. generate_rst(${PROJECT_SOURCE_DIR}/src/server/ua_services.h ${DOC_SRC_DIR}/services.rst)
  22. generate_rst(${PROJECT_SOURCE_DIR}/src/server/ua_nodestore.h ${DOC_SRC_DIR}/nodestore.rst)
  23. add_custom_target(doc_latex ${SPHINX_EXECUTABLE}
  24. -b latex "${DOC_SRC_DIR}" "${DOC_LATEX_DIR}"
  25. DEPENDS ${DOC_SRC_DIR}/types.rst ${DOC_SRC_DIR}/constants.rst ${DOC_SRC_DIR}/types_generated.rst
  26. ${DOC_SRC_DIR}/server.rst ${DOC_SRC_DIR}/client.rst ${DOC_SRC_DIR}/client_highlevel.rst
  27. ${DOC_SRC_DIR}/log.rst ${DOC_SRC_DIR}/connection.rst ${DOC_SRC_DIR}/services.rst ${DOC_SRC_DIR}/nodestore.rst
  28. COMMENT "Building LaTeX sources for documentation with Sphinx")
  29. add_dependencies(doc_latex open62541)
  30. add_custom_target(doc_pdf ${PDFLATEX_COMPILER} -q "open62541.tex"
  31. WORKING_DIRECTORY ${DOC_LATEX_DIR}
  32. # compile it twice so that the contents pages are correct
  33. COMMAND ${PDFLATEX_COMPILER} -q "open62541.tex"
  34. DEPENDS ${PDFLATEX_COMPILER}
  35. COMMENT "Generating PDF documentation from LaTeX sources")
  36. add_dependencies(doc_pdf doc_latex)
  37. add_custom_target(doc ${SPHINX_EXECUTABLE}
  38. -b html "${DOC_SRC_DIR}" "${DOC_HTML_DIR}"
  39. DEPENDS ${DOC_SRC_DIR}/types.rst ${DOC_SRC_DIR}/constants.rst ${DOC_SRC_DIR}/types_generated.rst
  40. ${DOC_SRC_DIR}/server.rst ${DOC_SRC_DIR}/client.rst ${DOC_SRC_DIR}/client_highlevel.rst
  41. ${DOC_SRC_DIR}/log.rst ${DOC_SRC_DIR}/connection.rst ${DOC_SRC_DIR}/services.rst ${DOC_SRC_DIR}/nodestore.rst
  42. COMMENT "Building HTML documentation with Sphinx")
  43. add_dependencies(doc open62541)