CMakeLists.txt 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/src_generated/tests")
  2. include_directories("${PROJECT_BINARY_DIR}/src_generated/tests")
  3. macro(generate_dataset xml source)
  4. add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/tests/${source}.c
  5. ${PROJECT_BINARY_DIR}/src_generated/tests/${source}.h
  6. PRE_BUILD
  7. COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodeset_compiler.py
  8. --types-array=UA_TYPES
  9. --existing ${UA_FILE_NS0}
  10. --xml ${xml}
  11. ${PROJECT_BINARY_DIR}/src_generated/tests/${source}
  12. DEPENDS ${UA_FILE_NS0} ${xml}
  13. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodeset_compiler.py
  14. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodes.py
  15. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodeset.py
  16. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/datatypes.py
  17. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/backend_open62541.py
  18. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/backend_open62541_nodes.py
  19. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/backend_open62541_datatypes.py)
  20. endmacro()
  21. # Check ObjectType
  22. generate_dataset(${PROJECT_SOURCE_DIR}/tests/nodeset-compiler/objecttype.xml check_nodeset_objecttype_generated)
  23. add_executable(check_nodeset_objecttype check_nodeset_objecttype.c
  24. ${PROJECT_BINARY_DIR}/src_generated/tests/check_nodeset_objecttype_generated.c
  25. $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  26. target_link_libraries(check_nodeset_objecttype ${LIBS})
  27. add_test_valgrind(nodeset_objecttype ${TESTS_BINARY_DIR}/check_nodeset_objecttype)
  28. ###############################################
  29. # Test Companion Specs that need the full NS0 #
  30. ###############################################
  31. if(UA_ENABLE_FULL_NS0)
  32. # Generate types for DI namespace
  33. set(UA_TYPES_OUT "ua_types_di")
  34. add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/tests/${UA_TYPES_OUT}_generated.c
  35. ${PROJECT_BINARY_DIR}/src_generated/tests/${UA_TYPES_OUT}_generated.h
  36. ${PROJECT_BINARY_DIR}/src_generated/tests/${UA_TYPES_OUT}_generated_handling.h
  37. ${PROJECT_BINARY_DIR}/src_generated/tests/${UA_TYPES_OUT}_generated_encoding_binary.h
  38. PRE_BUILD
  39. COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/generate_datatypes.py
  40. --namespace=2
  41. --type-csv=${PROJECT_SOURCE_DIR}/deps/ua-nodeset/DI/OpcUaDiModel.csv
  42. --type-bsd=${PROJECT_SOURCE_DIR}/deps/ua-nodeset/DI/Opc.Ua.Di.Types.bsd
  43. --no-builtin
  44. ${PROJECT_BINARY_DIR}/src_generated/tests/${UA_TYPES_OUT}
  45. DEPENDS ${PROJECT_SOURCE_DIR}/tools/generate_datatypes.py
  46. ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/DI/OpcUaDiModel.csv
  47. ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/DI/Opc.Ua.Di.Types.bsd)
  48. add_custom_target(open62541-generator-tests-types-di DEPENDS ${PROJECT_BINARY_DIR}/src_generated/tests/${UA_TYPES_OUT}_generated.c)
  49. # Generate types for ADI namespace
  50. set(UA_TYPES_OUT "ua_types_adi")
  51. add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/tests/${UA_TYPES_OUT}_generated.c
  52. ${PROJECT_BINARY_DIR}/src_generated/tests/${UA_TYPES_OUT}_generated.h
  53. ${PROJECT_BINARY_DIR}/src_generated/tests/${UA_TYPES_OUT}_generated_handling.h
  54. ${PROJECT_BINARY_DIR}/src_generated/tests/${UA_TYPES_OUT}_generated_encoding_binary.h
  55. PRE_BUILD
  56. COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/generate_datatypes.py
  57. --namespace=3
  58. --type-csv=${PROJECT_SOURCE_DIR}/deps/ua-nodeset/ADI/OpcUaAdiModel.csv
  59. --type-bsd=${PROJECT_SOURCE_DIR}/deps/ua-nodeset/ADI/Opc.Ua.Adi.Types.bsd
  60. --no-builtin
  61. ${PROJECT_BINARY_DIR}/src_generated/tests/${UA_TYPES_OUT}
  62. DEPENDS ${PROJECT_SOURCE_DIR}/tools/generate_datatypes.py
  63. ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/ADI/OpcUaAdiModel.csv
  64. ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/ADI/Opc.Ua.Adi.Types.bsd)
  65. add_custom_target(open62541-generator-tests-types-adi DEPENDS ${PROJECT_BINARY_DIR}/src_generated/tests/${UA_TYPES_OUT}_generated.c)
  66. # generate DI namespace
  67. add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/tests/ua_namespace_di.c
  68. ${PROJECT_BINARY_DIR}/src_generated/tests/ua_namespace_di.h
  69. PRE_BUILD
  70. COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodeset_compiler.py
  71. --internal-headers
  72. --types-array=UA_TYPES
  73. --types-array=UA_TYPES_DI
  74. --existing ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/Schema/Opc.Ua.NodeSet2.xml
  75. --xml ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/DI/Opc.Ua.Di.NodeSet2.xml
  76. ${PROJECT_BINARY_DIR}/src_generated/tests/ua_namespace_di
  77. DEPENDS ${UA_NAMESPACE0_XML}
  78. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodeset_compiler.py
  79. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodes.py
  80. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodeset.py
  81. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/datatypes.py
  82. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/backend_open62541.py
  83. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/backend_open62541_nodes.py
  84. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/backend_open62541_datatypes.py
  85. ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/Schema/Opc.Ua.NodeSet2.xml
  86. ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/DI/Opc.Ua.Di.NodeSet2.xml
  87. )
  88. add_custom_target(open62541-generator-tests-ns-di DEPENDS ${PROJECT_BINARY_DIR}/src_generated/tests/ua_namespace_di.c)
  89. add_dependencies(open62541-generator-tests-ns-di open62541-generator-tests-types-di)
  90. # generate ADI namespace which is using DI
  91. add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/tests/ua_namespace_adi.c
  92. ${PROJECT_BINARY_DIR}/src_generated/tests/ua_namespace_adi.h
  93. PRE_BUILD
  94. COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodeset_compiler.py
  95. --internal-headers
  96. --types-array=UA_TYPES
  97. --types-array=UA_TYPES_DI
  98. --types-array=UA_TYPES_ADI
  99. --existing ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/Schema/Opc.Ua.NodeSet2.xml
  100. --existing ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/DI/Opc.Ua.Di.NodeSet2.xml
  101. --xml ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/ADI/Opc.Ua.Adi.NodeSet2.xml
  102. ${PROJECT_BINARY_DIR}/src_generated/tests/ua_namespace_adi
  103. DEPENDS ${UA_NAMESPACE0_XML}
  104. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodeset_compiler.py
  105. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodes.py
  106. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodeset.py
  107. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/datatypes.py
  108. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/backend_open62541.py
  109. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/backend_open62541_nodes.py
  110. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/backend_open62541_datatypes.py
  111. ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/Schema/Opc.Ua.NodeSet2.xml
  112. ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/DI/Opc.Ua.Di.NodeSet2.xml
  113. ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/ADI/Opc.Ua.Adi.NodeSet2.xml
  114. )
  115. add_custom_target(open62541-generator-tests-ns-adi DEPENDS ${PROJECT_BINARY_DIR}/src_generated/tests/ua_namespace_adi.c)
  116. add_dependencies(open62541-generator-tests-ns-adi open62541-generator-tests-types-adi open62541-generator-tests-ns-di)
  117. # generate PLCopen namespace which is using DI
  118. add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/src_generated/tests/ua_namespace_plc.c
  119. ${PROJECT_BINARY_DIR}/src_generated/tests/ua_namespace_plc.h
  120. PRE_BUILD
  121. COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodeset_compiler.py
  122. --internal-headers
  123. --types-array=UA_TYPES
  124. --types-array=UA_TYPES_DI
  125. # PLCopen has no specific type definition, thus use the default UA_TYPES to ignore it
  126. --types-array=UA_TYPES
  127. --existing ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/Schema/Opc.Ua.NodeSet2.xml
  128. --existing ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/DI/Opc.Ua.Di.NodeSet2.xml
  129. --xml ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/PLCopen/Opc.Ua.Plc.NodeSet2.xml
  130. ${PROJECT_BINARY_DIR}/src_generated/tests/ua_namespace_plc
  131. DEPENDS ${UA_NAMESPACE0_XML}
  132. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodeset_compiler.py
  133. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodes.py
  134. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/nodeset.py
  135. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/datatypes.py
  136. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/backend_open62541.py
  137. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/backend_open62541_nodes.py
  138. ${PROJECT_SOURCE_DIR}/tools/nodeset_compiler/backend_open62541_datatypes.py
  139. ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/DI/Opc.Ua.Di.NodeSet2.xml
  140. ${PROJECT_SOURCE_DIR}/deps/ua-nodeset/PLCopen/Opc.Ua.Plc.NodeSet2.xml
  141. )
  142. add_custom_target(open62541-generator-tests-ns-plc DEPENDS ${PROJECT_BINARY_DIR}/src_generated/tests/ua_namespace_plc.c)
  143. add_dependencies(open62541-generator-tests-ns-plc open62541-generator-tests-ns-di)
  144. add_executable(check_nodeset_compiler_adi check_nodeset_compiler_adi.c
  145. ${PROJECT_BINARY_DIR}/src_generated/tests/ua_types_di_generated.c
  146. ${PROJECT_BINARY_DIR}/src_generated/tests/ua_namespace_di.c
  147. ${PROJECT_BINARY_DIR}/src_generated/tests/ua_types_adi_generated.c
  148. ${PROJECT_BINARY_DIR}/src_generated/tests/ua_namespace_adi.c
  149. $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  150. add_dependencies(check_nodeset_compiler_adi open62541-generator-tests-ns-adi)
  151. target_link_libraries(check_nodeset_compiler_adi ${LIBS})
  152. add_test_valgrind(nodeset_compiler_adi ${TESTS_BINARY_DIR}/check_nodeset_compiler_adi)
  153. add_executable(check_nodeset_compiler_plc check_nodeset_compiler_plc.c
  154. ${PROJECT_BINARY_DIR}/src_generated/tests/ua_types_di_generated.c
  155. ${PROJECT_BINARY_DIR}/src_generated/tests/ua_namespace_di.c
  156. ${PROJECT_BINARY_DIR}/src_generated/tests/ua_namespace_plc.c
  157. $<TARGET_OBJECTS:open62541-object> $<TARGET_OBJECTS:open62541-testplugins>)
  158. add_dependencies(check_nodeset_compiler_plc open62541-generator-tests-ns-plc)
  159. target_link_libraries(check_nodeset_compiler_plc ${LIBS})
  160. add_test_valgrind(nodeset_compiler_plc ${TESTS_BINARY_DIR}/check_nodeset_compiler_plc)
  161. endif()