CMakeLists.txt 4.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. list(REMOVE_ITEM DOC_SRC "${PROJECT_SOURCE_DIR}/doc/conf.py")
  9. list(REMOVE_ITEM DOC_SRC "${PROJECT_SOURCE_DIR}/doc/tutorial_server_variables.rst")
  10. list(REMOVE_ITEM DOC_SRC "${PROJECT_SOURCE_DIR}/doc/tutorial_server_method.rst")
  11. list(REMOVE_ITEM DOC_SRC "${PROJECT_SOURCE_DIR}/doc/tutorial_server_firstSteps.rst")
  12. list(REMOVE_ITEM DOC_SRC "${PROJECT_SOURCE_DIR}/doc/tutorial_client_firstSteps.rst")
  13. file(COPY ${DOC_SRC} DESTINATION ${DOC_SRC_DIR})
  14. configure_file("${PROJECT_SOURCE_DIR}/doc/conf.py" "${DOC_SRC_DIR}/conf.py")
  15. configure_file("${PROJECT_SOURCE_DIR}/doc/tutorial_server_variables.rst"
  16. "${DOC_SRC_DIR}/tutorial_server_variables.rst")
  17. configure_file("${PROJECT_SOURCE_DIR}/doc/tutorial_server_method.rst"
  18. "${DOC_SRC_DIR}/tutorial_server_method.rst")
  19. configure_file("${PROJECT_SOURCE_DIR}/doc/tutorial_server_firstSteps.rst"
  20. "${DOC_SRC_DIR}/tutorial_server_firstSteps.rst")
  21. configure_file("${PROJECT_SOURCE_DIR}/doc/tutorial_client_firstSteps.rst"
  22. "${DOC_SRC_DIR}/tutorial_client_firstSteps.rst")
  23. # Copy example code
  24. set(EXAMPLES ${PROJECT_SOURCE_DIR}/examples/client_firstSteps.c
  25. ${PROJECT_SOURCE_DIR}/examples/server_firstSteps.c
  26. ${PROJECT_SOURCE_DIR}/examples/server_variable.c
  27. ${PROJECT_SOURCE_DIR}/examples/server_method.c)
  28. file(COPY ${EXAMPLES} DESTINATION ${DOC_SRC_DIR})
  29. function(generate_rst in out)
  30. add_custom_command(OUTPUT ${out} DEPENDS ${PROJECT_SOURCE_DIR}/tools/c2rst.py ${in}
  31. PRE_BUILD COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/c2rst.py ${in} ${out})
  32. endfunction()
  33. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_types.h ${DOC_SRC_DIR}/types.rst)
  34. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_constants.h ${DOC_SRC_DIR}/constants.rst)
  35. generate_rst(${PROJECT_BINARY_DIR}/src_generated/ua_types_generated.h ${DOC_SRC_DIR}/types_generated.rst)
  36. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_server.h ${DOC_SRC_DIR}/server.rst)
  37. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_client.h ${DOC_SRC_DIR}/client.rst)
  38. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_client_highlevel.h ${DOC_SRC_DIR}/client_highlevel.rst)
  39. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_log.h ${DOC_SRC_DIR}/log.rst)
  40. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_connection.h ${DOC_SRC_DIR}/connection.rst)
  41. generate_rst(${PROJECT_SOURCE_DIR}/src/server/ua_services.h ${DOC_SRC_DIR}/services.rst)
  42. generate_rst(${PROJECT_SOURCE_DIR}/src/server/ua_nodestore.h ${DOC_SRC_DIR}/nodestore.rst)
  43. generate_rst(${PROJECT_SOURCE_DIR}/src/server/ua_nodes.h ${DOC_SRC_DIR}/information_modelling.rst)
  44. add_custom_target(doc_latex ${SPHINX_EXECUTABLE}
  45. -b latex "${DOC_SRC_DIR}" "${DOC_LATEX_DIR}"
  46. DEPENDS ${DOC_SRC_DIR}/types.rst ${DOC_SRC_DIR}/constants.rst ${DOC_SRC_DIR}/types_generated.rst
  47. ${DOC_SRC_DIR}/server.rst ${DOC_SRC_DIR}/client.rst ${DOC_SRC_DIR}/client_highlevel.rst
  48. ${DOC_SRC_DIR}/log.rst ${DOC_SRC_DIR}/connection.rst ${DOC_SRC_DIR}/services.rst
  49. ${DOC_SRC_DIR}/nodestore.rst ${DOC_SRC_DIR}/information_modelling.rst
  50. ${DOC_SRC_DIR}/protocol.rst
  51. COMMENT "Building LaTeX sources for documentation with Sphinx")
  52. add_dependencies(doc_latex open62541)
  53. add_custom_target(doc_pdf ${PDFLATEX_COMPILER} -q "open62541.tex"
  54. WORKING_DIRECTORY ${DOC_LATEX_DIR}
  55. # compile it twice so that the contents pages are correct
  56. COMMAND ${PDFLATEX_COMPILER} -q "open62541.tex"
  57. DEPENDS ${PDFLATEX_COMPILER}
  58. COMMENT "Generating PDF documentation from LaTeX sources")
  59. add_dependencies(doc_pdf doc_latex)
  60. add_custom_target(doc ${SPHINX_EXECUTABLE}
  61. -b html "${DOC_SRC_DIR}" "${DOC_HTML_DIR}"
  62. DEPENDS ${DOC_SRC_DIR}/types.rst ${DOC_SRC_DIR}/constants.rst ${DOC_SRC_DIR}/types_generated.rst
  63. ${DOC_SRC_DIR}/server.rst ${DOC_SRC_DIR}/client.rst ${DOC_SRC_DIR}/client_highlevel.rst
  64. ${DOC_SRC_DIR}/log.rst ${DOC_SRC_DIR}/connection.rst ${DOC_SRC_DIR}/services.rst
  65. ${DOC_SRC_DIR}/nodestore.rst ${DOC_SRC_DIR}/information_modelling.rst
  66. ${DOC_SRC_DIR}/protocol.rst
  67. COMMENT "Building HTML documentation with Sphinx")
  68. add_dependencies(doc open62541)