CMakeLists.txt 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. ####################
  2. # Nodeset Examples #
  3. ####################
  4. ###################
  5. # Custom XML #
  6. ###################
  7. # generate namespace from XML file
  8. ua_generate_nodeset_and_datatypes(
  9. NAME "example"
  10. FILE_NS "${PROJECT_SOURCE_DIR}/examples/nodeset/server_nodeset.xml"
  11. )
  12. # The .csv file can be created from within UaModeler or manually
  13. add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/example_nodeset_ids.h
  14. PRE_BUILD
  15. COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/generate_nodeid_header.py
  16. ${PROJECT_SOURCE_DIR}/examples/nodeset/server_nodeset.csv ${PROJECT_BINARY_DIR}/src_generated/example_nodeset_ids EXAMPLE_NS
  17. DEPENDS ${PROJECT_SOURCE_DIR}/tools/generate_nodeid_header.py
  18. ${PROJECT_SOURCE_DIR}/examples/nodeset/server_nodeset.csv)
  19. add_example(server_nodeset server_nodeset.c ${PROJECT_BINARY_DIR}/src_generated/ua_namespace_example.c ${PROJECT_BINARY_DIR}/src_generated/example_nodeset_ids.h)
  20. if(UA_COMPILE_AS_CXX)
  21. set_source_files_properties(${PROJECT_BINARY_DIR}/src_generated/ua_namespace_example.c PROPERTIES LANGUAGE CXX)
  22. endif()
  23. ###################
  24. # PLCopen Nodeset #
  25. ###################
  26. # PLCopen requires the full ns0 as basis
  27. if(UA_NAMESPACE_ZERO STREQUAL "FULL")
  28. # Generate types and namespace for DI
  29. ua_generate_nodeset_and_datatypes(
  30. NAME "di"
  31. FILE_CSV "${PROJECT_SOURCE_DIR}/deps/ua-nodeset/DI/OpcUaDiModel.csv"
  32. FILE_BSD "${PROJECT_SOURCE_DIR}/deps/ua-nodeset/DI/Opc.Ua.Di.Types.bsd"
  33. NAMESPACE_IDX 2
  34. FILE_NS "${PROJECT_SOURCE_DIR}/deps/ua-nodeset/DI/Opc.Ua.Di.NodeSet2.xml"
  35. INTERNAL
  36. )
  37. # generate PLCopen namespace which is using DI
  38. ua_generate_nodeset_and_datatypes(
  39. NAME "plc"
  40. # PLCopen does not define custom types. Only generate the nodeset
  41. FILE_NS "${PROJECT_SOURCE_DIR}/deps/ua-nodeset/PLCopen/Opc.Ua.Plc.NodeSet2.xml"
  42. # PLCopen depends on the di nodeset, which must be generated before
  43. DEPENDS "di"
  44. INTERNAL
  45. )
  46. add_example(server_nodeset_plcopen server_nodeset_plcopen.c
  47. ${PROJECT_BINARY_DIR}/src_generated/ua_types_di_generated.c
  48. ${PROJECT_BINARY_DIR}/src_generated/ua_namespace_di.c
  49. ${PROJECT_BINARY_DIR}/src_generated/ua_namespace_plc.c)
  50. add_dependencies(server_nodeset_plcopen open62541-generator-ns-plc)
  51. target_include_directories(server_nodeset_plcopen PRIVATE ${PROJECT_SOURCE_DIR}/src) # needs an internal header
  52. endif()