CMakeLists.txt 5.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. find_package(Sphinx)
  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. file(COPY ${DOC_SRC} DESTINATION ${DOC_SRC_DIR})
  10. configure_file("${PROJECT_SOURCE_DIR}/doc/conf.py" "${DOC_SRC_DIR}/conf.py")
  11. function(generate_rst in out)
  12. add_custom_command(OUTPUT ${out} DEPENDS ${PROJECT_SOURCE_DIR}/tools/c2rst.py ${in}
  13. PRE_BUILD COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/c2rst.py ${in} ${out})
  14. endfunction()
  15. # Doc from headers
  16. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_types.h ${DOC_SRC_DIR}/types.rst)
  17. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_constants.h ${DOC_SRC_DIR}/constants.rst)
  18. generate_rst(${PROJECT_BINARY_DIR}/src_generated/ua_types_generated.h ${DOC_SRC_DIR}/types_generated.rst)
  19. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_server.h ${DOC_SRC_DIR}/server.rst)
  20. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_client.h ${DOC_SRC_DIR}/client.rst)
  21. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_client_highlevel.h ${DOC_SRC_DIR}/client_highlevel.rst)
  22. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_plugin_log.h ${DOC_SRC_DIR}/plugin_log.rst)
  23. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_plugin_network.h ${DOC_SRC_DIR}/plugin_network.rst)
  24. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_plugin_access_control.h ${DOC_SRC_DIR}/plugin_access_control.rst)
  25. generate_rst(${PROJECT_SOURCE_DIR}/src/server/ua_services.h ${DOC_SRC_DIR}/services.rst)
  26. generate_rst(${PROJECT_SOURCE_DIR}/src/server/ua_nodestore.h ${DOC_SRC_DIR}/nodestore.rst)
  27. generate_rst(${PROJECT_SOURCE_DIR}/src/server/ua_nodes.h ${DOC_SRC_DIR}/information_modelling.rst)
  28. # Doc from tutorial code
  29. generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_datatypes.c ${DOC_SRC_DIR}/tutorial_datatypes.rst)
  30. generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_server_firststeps.c ${DOC_SRC_DIR}/tutorial_server_firststeps.rst)
  31. generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_server_variable.c ${DOC_SRC_DIR}/tutorial_server_variable.rst)
  32. generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_server_variabletype.c ${DOC_SRC_DIR}/tutorial_server_variabletype.rst)
  33. generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_server_datasource.c ${DOC_SRC_DIR}/tutorial_server_datasource.rst)
  34. generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_server_object.c ${DOC_SRC_DIR}/tutorial_server_object.rst)
  35. generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_server_method.c ${DOC_SRC_DIR}/tutorial_server_method.rst)
  36. generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_client_firststeps.c ${DOC_SRC_DIR}/tutorial_client_firststeps.rst)
  37. add_custom_target(doc_latex ${SPHINX_EXECUTABLE}
  38. -b latex "${DOC_SRC_DIR}" "${DOC_LATEX_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}/plugin_log.rst ${DOC_SRC_DIR}/plugin_network.rst
  42. ${DOC_SRC_DIR}/services.rst ${DOC_SRC_DIR}/plugin_access_control.rst
  43. ${DOC_SRC_DIR}/nodestore.rst ${DOC_SRC_DIR}/information_modelling.rst
  44. ${DOC_SRC_DIR}/tutorial_datatypes.rst
  45. ${DOC_SRC_DIR}/tutorial_client_firststeps.rst
  46. ${DOC_SRC_DIR}/tutorial_server_firststeps.rst
  47. ${DOC_SRC_DIR}/tutorial_server_variable.rst
  48. ${DOC_SRC_DIR}/tutorial_server_variabletype.rst
  49. ${DOC_SRC_DIR}/tutorial_server_datasource.rst
  50. ${DOC_SRC_DIR}/tutorial_server_object.rst
  51. ${DOC_SRC_DIR}/tutorial_server_method.rst
  52. COMMENT "Building LaTeX sources for documentation with Sphinx")
  53. add_dependencies(doc_latex open62541)
  54. add_custom_target(doc_pdf ${PDFLATEX_COMPILER} --quiet "open62541.tex"
  55. WORKING_DIRECTORY ${DOC_LATEX_DIR}
  56. # compile it twice so that the contents pages are correct
  57. COMMAND ${PDFLATEX_COMPILER} --quiet "open62541.tex"
  58. DEPENDS ${PDFLATEX_COMPILER}
  59. COMMENT "Generating PDF documentation from LaTeX sources")
  60. add_dependencies(doc_pdf doc_latex)
  61. add_custom_target(doc ${SPHINX_EXECUTABLE}
  62. -b html "${DOC_SRC_DIR}" "${DOC_HTML_DIR}"
  63. DEPENDS ${DOC_SRC_DIR}/types.rst ${DOC_SRC_DIR}/constants.rst ${DOC_SRC_DIR}/types_generated.rst
  64. ${DOC_SRC_DIR}/server.rst ${DOC_SRC_DIR}/client.rst ${DOC_SRC_DIR}/client_highlevel.rst
  65. ${DOC_SRC_DIR}/plugin_log.rst ${DOC_SRC_DIR}/plugin_network.rst
  66. ${DOC_SRC_DIR}/services.rst ${DOC_SRC_DIR}/plugin_access_control.rst
  67. ${DOC_SRC_DIR}/nodestore.rst ${DOC_SRC_DIR}/information_modelling.rst
  68. ${DOC_SRC_DIR}/tutorial_datatypes.rst
  69. ${DOC_SRC_DIR}/tutorial_client_firststeps.rst
  70. ${DOC_SRC_DIR}/tutorial_server_firststeps.rst
  71. ${DOC_SRC_DIR}/tutorial_server_variable.rst
  72. ${DOC_SRC_DIR}/tutorial_server_variabletype.rst
  73. ${DOC_SRC_DIR}/tutorial_server_datasource.rst
  74. ${DOC_SRC_DIR}/tutorial_server_object.rst
  75. ${DOC_SRC_DIR}/tutorial_server_method.rst
  76. COMMENT "Building HTML documentation with Sphinx")
  77. add_dependencies(doc open62541)
  78. set_target_properties(doc doc_latex doc_pdf PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD TRUE)
  79. set_target_properties(doc doc_latex doc_pdf PROPERTIES FOLDER "open62541/doc")