CMakeLists.txt 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. ####################
  2. # Nodeset Examples #
  3. ####################
  4. ###################
  5. # Custom XML #
  6. ###################
  7. set(FILE_CSV_DIRPREFIX ${PROJECT_SOURCE_DIR}/nodeset)
  8. set(FILE_BSD_DIRPREFIX ${PROJECT_SOURCE_DIR}/nodeset)
  9. set(FILE_NS_DIRPREFIX ${PROJECT_SOURCE_DIR}/nodeset)
  10. if(NOT CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
  11. # needed or cmake doesn't recognize dependencies of generated files
  12. set(PROJECT_BINARY_DIR ${CMAKE_BINARY_DIR})
  13. endif()
  14. # generate namespace from XML file
  15. if(NOT CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
  16. ua_generate_nodeset_and_datatypes(
  17. NAME "example"
  18. FILE_NS "${FILE_NS_DIRPREFIX}/server_nodeset.xml"
  19. DEPENDS "${CMAKE_SOURCE_DIR}/tools/schema/Opc.Ua.NodeSet2.Reduced.xml"
  20. )
  21. else()
  22. # standalone examples build expects already installed Opc.Ua.NodeSet2.Reduced.xml
  23. ua_generate_nodeset_and_datatypes(
  24. NAME "example"
  25. FILE_NS "${FILE_NS_DIRPREFIX}/server_nodeset.xml"
  26. )
  27. endif()
  28. # The .csv file can be created from within UaModeler or manually
  29. ua_generate_nodeid_header(
  30. NAME "example_nodeids"
  31. ID_PREFIX "EXAMPLE_NS"
  32. TARGET_SUFFIX "ids_example"
  33. FILE_CSV "${FILE_CSV_DIRPREFIX}/server_nodeset.csv"
  34. )
  35. add_example(server_nodeset server_nodeset.c
  36. ${UA_NODESET_EXAMPLE_SOURCES}
  37. ${PROJECT_BINARY_DIR}/src_generated/open62541/example_nodeids.h)
  38. if(UA_NAMESPACE_ZERO STREQUAL "FULL")
  39. ua_generate_nodeset_and_datatypes(
  40. NAME "testnodeset"
  41. FILE_CSV "${FILE_CSV_DIRPREFIX}/testnodeset.csv"
  42. FILE_BSD "${FILE_BSD_DIRPREFIX}/testtypes.bsd"
  43. NAMESPACE_IDX 2
  44. FILE_NS "${FILE_NS_DIRPREFIX}/testnodeset.xml"
  45. INTERNAL
  46. )
  47. add_example(server_testnodeset server_testnodeset.c
  48. ${UA_NODESET_TESTNODESET_SOURCES}
  49. ${UA_TYPES_TESTNODESET_SOURCES})
  50. add_dependencies(server_testnodeset open62541-generator-ns-testnodeset)
  51. endif()
  52. ###################
  53. # PLCopen Nodeset #
  54. ###################
  55. if(NOT CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
  56. set(FILE_CSV_DIRPREFIX ${CMAKE_SOURCE_DIR}/deps/ua-nodeset)
  57. set(FILE_BSD_PLCOPEN_DIRPREFIX ${CMAKE_SOURCE_DIR}/deps/ua-nodeset)
  58. set(FILE_BSD_POWERLINK_DIRPREFIX ${PROJECT_SOURCE_DIR}/nodeset)
  59. set(FILE_NS_DIRPREFIX ${CMAKE_SOURCE_DIR}/deps/ua-nodeset)
  60. else()
  61. set(FILE_CSV_DIRPREFIX ${UA_NODESET_DIR})
  62. set(FILE_BSD_PLCOPEN_DIRPREFIX ${UA_NODESET_DIR})
  63. set(FILE_BSD_POWERLINK_DIRPREFIX ${PROJECT_SOURCE_DIR}/nodeset)
  64. set(FILE_NS_DIRPREFIX ${UA_NODESET_DIR})
  65. endif()
  66. # PLCopen requires the full ns0 as basis
  67. if(UA_NAMESPACE_ZERO STREQUAL "FULL")
  68. # Generate types and namespace for DI
  69. ua_generate_nodeset_and_datatypes(
  70. NAME "di"
  71. FILE_CSV "${FILE_CSV_DIRPREFIX}/DI/OpcUaDiModel.csv"
  72. FILE_BSD "${FILE_BSD_PLCOPEN_DIRPREFIX}/DI/Opc.Ua.Di.Types.bsd"
  73. NAMESPACE_IDX 2
  74. FILE_NS "${FILE_NS_DIRPREFIX}/DI/Opc.Ua.Di.NodeSet2.xml"
  75. INTERNAL
  76. )
  77. # generate PLCopen namespace which is using DI
  78. ua_generate_nodeset_and_datatypes(
  79. NAME "plc"
  80. # PLCopen does not define custom types. Only generate the nodeset
  81. FILE_NS "${FILE_NS_DIRPREFIX}/PLCopen/Opc.Ua.Plc.NodeSet2.xml"
  82. # PLCopen depends on the di nodeset, which must be generated before
  83. DEPENDS "di"
  84. INTERNAL
  85. )
  86. add_example(server_nodeset_plcopen server_nodeset_plcopen.c
  87. ${UA_NODESET_DI_SOURCES}
  88. ${UA_NODESET_PLC_SOURCES}
  89. ${UA_TYPES_DI_SOURCES}
  90. ${UA_TYPES_PLC_SOURCES})
  91. add_dependencies(server_nodeset_plcopen open62541-generator-ns-plc)
  92. endif()
  93. # POWERLINK requires the full ns0 as basis
  94. if(UA_NAMESPACE_ZERO STREQUAL "FULL")
  95. # generate powerlink namespace which is using DI
  96. ua_generate_nodeset_and_datatypes(
  97. NAME "powerlink"
  98. FILE_CSV "${FILE_CSV_DIRPREFIX}/POWERLINK/Opc.Ua.POWERLINK.NodeIds.csv"
  99. FILE_BSD "${FILE_BSD_POWERLINK_DIRPREFIX}/Opc.Ua.POWERLINK.NodeSet2.bsd"
  100. NAMESPACE_IDX 3
  101. FILE_NS "${FILE_NS_DIRPREFIX}/POWERLINK/Opc.Ua.POWERLINK.NodeSet2.xml"
  102. # POWERLINK depends on the di nodeset, which must be generated before
  103. DEPENDS "di"
  104. INTERNAL
  105. )
  106. add_example(server_nodeset_powerlink server_nodeset_powerlink.c
  107. ${UA_NODESET_DI_SOURCES}
  108. ${UA_NODESET_POWERLINK_SOURCES}
  109. ${UA_TYPES_DI_SOURCES}
  110. ${UA_TYPES_POWERLINK_SOURCES})
  111. add_dependencies(server_nodeset_powerlink open62541-generator-ns-powerlink)
  112. endif()