CMakeLists.txt 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. ####################
  2. # Nodeset Examples #
  3. ####################
  4. ###################
  5. # Custom XML #
  6. ###################
  7. # generate namespace from XML file
  8. add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/example_nodeset.c
  9. ${PROJECT_BINARY_DIR}/src_generated/example_nodeset.h
  10. PRE_BUILD
  11. COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodeset_compiler.py
  12. --types-array=UA_TYPES
  13. --existing ${UA_FILE_NS0}
  14. --xml ${PROJECT_SOURCE_DIR}/examples/nodeset/server_nodeset.xml
  15. ${PROJECT_BINARY_DIR}/src_generated/example_nodeset
  16. DEPENDS ${UA_FILE_NS0}
  17. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodeset_compiler.py
  18. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodes.py
  19. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodeset.py
  20. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/datatypes.py
  21. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/backend_open62541.py
  22. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/backend_open62541_nodes.py
  23. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/backend_open62541_datatypes.py
  24. ${PROJECT_SOURCE_DIR}/examples/nodeset/server_nodeset.xml)
  25. add_example(server_nodeset server_nodeset.c ${PROJECT_BINARY_DIR}/src_generated/example_nodeset.c)
  26. if(UA_COMPILE_AS_CXX)
  27. set_source_files_properties(${PROJECT_BINARY_DIR}/src_generated/example_nodeset.c PROPERTIES LANGUAGE CXX)
  28. endif()
  29. ###################
  30. # PLCopen Nodeset #
  31. ###################
  32. # PLCopen requires the full ns0 as basis
  33. if(UA_ENABLE_FULL_NS0)
  34. # Generate types for DI namespace
  35. set(UA_TYPES_OUT "ua_types_di")
  36. add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/${UA_TYPES_OUT}_generated.c
  37. ${PROJECT_BINARY_DIR}/src_generated/${UA_TYPES_OUT}_generated.h
  38. ${PROJECT_BINARY_DIR}/src_generated/${UA_TYPES_OUT}_generated_handling.h
  39. ${PROJECT_BINARY_DIR}/src_generated/${UA_TYPES_OUT}_generated_encoding_binary.h
  40. PRE_BUILD
  41. COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/generate_datatypes.py
  42. --namespace=2
  43. --type-csv=${PROJECT_SOURCE_DIR}/deps/ua-nodeset/DI/OpcUaDiModel.csv
  44. --type-bsd=${PROJECT_SOURCE_DIR}/deps/ua-nodeset/DI/Opc.Ua.Di.Types.bsd
  45. --no-builtin
  46. ${PROJECT_BINARY_DIR}/src_generated/${UA_TYPES_OUT}
  47. DEPENDS ${PROJECT_SOURCE_DIR}/tools/generate_datatypes.py
  48. ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/DI/OpcUaDiModel.csv
  49. ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/DI/Opc.Ua.Di.Types.bsd)
  50. add_custom_target(open62541-generator-types-di DEPENDS ${PROJECT_BINARY_DIR}/src_generated/${UA_TYPES_OUT}_generated.c)
  51. # generate DI namespace
  52. add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/ua_namespace_di.c
  53. ${PROJECT_BINARY_DIR}/src_generated/ua_namespace_di.h
  54. PRE_BUILD
  55. COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodeset_compiler.py
  56. --internal-headers
  57. --types-array=UA_TYPES
  58. --types-array=UA_TYPES_DI
  59. --existing ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/Schema/Opc.Ua.NodeSet2.xml
  60. --xml ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/DI/Opc.Ua.Di.NodeSet2.xml
  61. ${PROJECT_BINARY_DIR}/src_generated/ua_namespace_di
  62. DEPENDS ${UA_FILE_NS0}
  63. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodeset_compiler.py
  64. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodes.py
  65. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodeset.py
  66. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/datatypes.py
  67. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/backend_open62541.py
  68. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/backend_open62541_nodes.py
  69. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/backend_open62541_datatypes.py
  70. ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/Schema/Opc.Ua.NodeSet2.xml
  71. ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/DI/Opc.Ua.Di.NodeSet2.xml
  72. )
  73. add_custom_target(open62541-generator-ns-di DEPENDS ${PROJECT_BINARY_DIR}/src_generated/ua_namespace_di.c)
  74. add_dependencies(open62541-generator-ns-di open62541-generator-types-di)
  75. # generate PLCopen namespace which is using DI
  76. add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/ua_namespace_plc.c
  77. ${PROJECT_BINARY_DIR}/src_generated/ua_namespace_plc.h
  78. PRE_BUILD
  79. COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodeset_compiler.py
  80. --internal-headers
  81. --types-array=UA_TYPES
  82. --types-array=UA_TYPES_DI
  83. # PLCopen has no specific type definition, thus use the default UA_TYPES to ignore it
  84. --types-array=UA_TYPES
  85. --existing ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/Schema/Opc.Ua.NodeSet2.xml
  86. --existing ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/DI/Opc.Ua.Di.NodeSet2.xml
  87. --xml ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/PLCopen/Opc.Ua.Plc.NodeSet2.xml
  88. ${PROJECT_BINARY_DIR}/src_generated/ua_namespace_plc
  89. DEPENDS ${UA_FILE_NS0}
  90. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodeset_compiler.py
  91. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodes.py
  92. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodeset.py
  93. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/datatypes.py
  94. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/backend_open62541.py
  95. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/backend_open62541_nodes.py
  96. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/backend_open62541_datatypes.py
  97. ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/Schema/Opc.Ua.NodeSet2.xml
  98. ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/DI/Opc.Ua.Di.NodeSet2.xml
  99. ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/PLCopen/Opc.Ua.Plc.NodeSet2.xml
  100. )
  101. add_custom_target(open62541-generator-ns-plc DEPENDS ${PROJECT_BINARY_DIR}/src_generated/ua_namespace_plc.c)
  102. add_dependencies(open62541-generator-ns-plc open62541-generator-ns-di)
  103. add_example(server_nodeset_plcopen server_nodeset_plcopen.c
  104. ${PROJECT_BINARY_DIR}/src_generated/ua_types_di_generated.c
  105. ${PROJECT_BINARY_DIR}/src_generated/ua_namespace_di.c
  106. ${PROJECT_BINARY_DIR}/src_generated/ua_namespace_plc.c)
  107. add_dependencies(server_nodeset_plcopen open62541-generator-ns-plc)
  108. target_include_directories(server_nodeset_plcopen PRIVATE ${PROJECT_SOURCE_DIR}/src) # needs an internal header
  109. if(UA_COMPILE_AS_CXX)
  110. set_source_files_properties(${PROJECT_BINARY_DIR}/src_generated/ua_types_di_generated.c PROPERTIES LANGUAGE CXX)
  111. set_source_files_properties(${PROJECT_BINARY_DIR}/src_generated/ua_namespace_di.c PROPERTIES LANGUAGE CXX)
  112. set_source_files_properties(${PROJECT_BINARY_DIR}/src_generated/ua_namespace_plc.c PROPERTIES LANGUAGE CXX)
  113. endif()
  114. endif()