CMakeLists.txt 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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_config.h ${DOC_SRC_DIR}/server_config.rst)
  20. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_server.h ${DOC_SRC_DIR}/server.rst)
  21. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_client_config.h ${DOC_SRC_DIR}/client_config.rst)
  22. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_client_subscriptions.h ${DOC_SRC_DIR}/client_subscriptions.rst)
  23. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_client.h ${DOC_SRC_DIR}/client.rst)
  24. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_client_highlevel.h ${DOC_SRC_DIR}/client_highlevel.rst)
  25. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_plugin_log.h ${DOC_SRC_DIR}/plugin_log.rst)
  26. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_plugin_network.h ${DOC_SRC_DIR}/plugin_network.rst)
  27. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_plugin_access_control.h ${DOC_SRC_DIR}/plugin_access_control.rst)
  28. generate_rst(${PROJECT_SOURCE_DIR}/src/server/ua_services.h ${DOC_SRC_DIR}/services.rst)
  29. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_plugin_nodestore.h ${DOC_SRC_DIR}/nodestore.rst)
  30. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_plugin_pubsub.h ${DOC_SRC_DIR}/plugin_pubsub_connection.rst)
  31. generate_rst(${PROJECT_SOURCE_DIR}/include/ua_server_pubsub.h ${DOC_SRC_DIR}/pubsub.rst)
  32. # Doc from tutorial code
  33. generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_datatypes.c ${DOC_SRC_DIR}/tutorial_datatypes.rst)
  34. generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_server_firststeps.c ${DOC_SRC_DIR}/tutorial_server_firststeps.rst)
  35. generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_server_variable.c ${DOC_SRC_DIR}/tutorial_server_variable.rst)
  36. generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_server_variabletype.c ${DOC_SRC_DIR}/tutorial_server_variabletype.rst)
  37. generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_server_datasource.c ${DOC_SRC_DIR}/tutorial_server_datasource.rst)
  38. generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_server_object.c ${DOC_SRC_DIR}/tutorial_server_object.rst)
  39. generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_server_method.c ${DOC_SRC_DIR}/tutorial_server_method.rst)
  40. generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_client_firststeps.c ${DOC_SRC_DIR}/tutorial_client_firststeps.rst)
  41. add_custom_target(doc_latex ${SPHINX_EXECUTABLE}
  42. -b latex "${DOC_SRC_DIR}" "${DOC_LATEX_DIR}"
  43. DEPENDS ${DOC_SRC_DIR}/types.rst ${DOC_SRC_DIR}/constants.rst ${DOC_SRC_DIR}/types_generated.rst
  44. ${DOC_SRC_DIR}/server.rst ${DOC_SRC_DIR}/server_config.rst
  45. ${DOC_SRC_DIR}/client.rst ${DOC_SRC_DIR}/client_subscriptions.rst
  46. ${DOC_SRC_DIR}/client_highlevel.rst ${DOC_SRC_DIR}/client_config.rst
  47. ${DOC_SRC_DIR}/plugin_log.rst ${DOC_SRC_DIR}/plugin_network.rst
  48. ${DOC_SRC_DIR}/services.rst ${DOC_SRC_DIR}/plugin_access_control.rst
  49. ${DOC_SRC_DIR}/nodestore.rst
  50. ${DOC_SRC_DIR}/tutorials.rst
  51. ${DOC_SRC_DIR}/tutorial_datatypes.rst
  52. ${DOC_SRC_DIR}/tutorial_client_firststeps.rst
  53. ${DOC_SRC_DIR}/tutorial_server_firststeps.rst
  54. ${DOC_SRC_DIR}/tutorial_server_variable.rst
  55. ${DOC_SRC_DIR}/tutorial_server_variabletype.rst
  56. ${DOC_SRC_DIR}/tutorial_server_datasource.rst
  57. ${DOC_SRC_DIR}/tutorial_server_object.rst
  58. ${DOC_SRC_DIR}/tutorial_server_method.rst
  59. ${DOC_SRC_DIR}/plugin_pubsub_connection.rst
  60. ${DOC_SRC_DIR}/pubsub.rst
  61. COMMENT "Building LaTeX sources for documentation with Sphinx")
  62. add_dependencies(doc_latex open62541)
  63. add_custom_target(doc_pdf ${PDFLATEX_COMPILER} -interaction=batchmode "open62541.tex"
  64. WORKING_DIRECTORY ${DOC_LATEX_DIR}
  65. # compile it twice so that the contents pages are correct
  66. COMMAND ${PDFLATEX_COMPILER} -interaction=batchmode "open62541.tex"
  67. DEPENDS ${PDFLATEX_COMPILER}
  68. COMMENT "Generating PDF documentation from LaTeX sources")
  69. add_dependencies(doc_pdf doc_latex)
  70. add_custom_target(doc ${SPHINX_EXECUTABLE}
  71. -b html "${DOC_SRC_DIR}" "${DOC_HTML_DIR}"
  72. DEPENDS ${DOC_SRC_DIR}/types.rst ${DOC_SRC_DIR}/constants.rst ${DOC_SRC_DIR}/types_generated.rst
  73. ${DOC_SRC_DIR}/server.rst ${DOC_SRC_DIR}/server_config.rst
  74. ${DOC_SRC_DIR}/client.rst ${DOC_SRC_DIR}/client_subscriptions.rst
  75. ${DOC_SRC_DIR}/client_highlevel.rst ${DOC_SRC_DIR}/client_config.rst
  76. ${DOC_SRC_DIR}/plugin_log.rst ${DOC_SRC_DIR}/plugin_network.rst
  77. ${DOC_SRC_DIR}/services.rst ${DOC_SRC_DIR}/plugin_access_control.rst
  78. ${DOC_SRC_DIR}/nodestore.rst
  79. ${DOC_SRC_DIR}/tutorials.rst
  80. ${DOC_SRC_DIR}/tutorial_datatypes.rst
  81. ${DOC_SRC_DIR}/tutorial_client_firststeps.rst
  82. ${DOC_SRC_DIR}/tutorial_server_firststeps.rst
  83. ${DOC_SRC_DIR}/tutorial_server_variable.rst
  84. ${DOC_SRC_DIR}/tutorial_server_variabletype.rst
  85. ${DOC_SRC_DIR}/tutorial_server_datasource.rst
  86. ${DOC_SRC_DIR}/tutorial_server_object.rst
  87. ${DOC_SRC_DIR}/tutorial_server_method.rst
  88. ${DOC_SRC_DIR}/plugin_pubsub_connection.rst
  89. ${DOC_SRC_DIR}/pubsub.rst
  90. COMMENT "Building HTML documentation with Sphinx")
  91. add_dependencies(doc open62541)
  92. set_target_properties(doc doc_latex doc_pdf PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD TRUE)
  93. set_target_properties(doc doc_latex doc_pdf PROPERTIES FOLDER "open62541/doc")