CMakeLists.txt 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. include_directories(${PROJECT_SOURCE_DIR}/include)
  2. include_directories(${PROJECT_SOURCE_DIR}/deps)
  3. include_directories(${PROJECT_SOURCE_DIR}/src)
  4. include_directories(${PROJECT_SOURCE_DIR}/plugins)
  5. include_directories(${PROJECT_BINARY_DIR}/src_generated)
  6. include_directories(${CHECK_INCLUDE_DIRS})
  7. find_package(Check REQUIRED)
  8. find_package(Threads REQUIRED)
  9. set(LIBS ${CHECK_LIBRARIES} ${open62541_LIBRARIES})
  10. if(NOT WIN32)
  11. list(APPEND LIBS pthread m)
  12. if (NOT APPLE)
  13. list(APPEND LIBS rt subunit)
  14. endif()
  15. else()
  16. list(APPEND LIBS ws2_32)
  17. endif()
  18. if(UA_ENABLE_MULTITHREADING)
  19. list(APPEND LIBS urcu-cds urcu urcu-common)
  20. endif()
  21. if(CMAKE_COMPILER_IS_GNUCC OR "x${CMAKE_C_COMPILER_ID}" STREQUAL "xClang")
  22. add_definitions(-Wno-sign-conversion)
  23. endif()
  24. # the unit test are built directly on the open62541 object files. so they can
  25. # access symbols that are hidden/not exported to the shared library
  26. add_executable(check_types_builtin check_types_builtin.c $<TARGET_OBJECTS:open62541-object>)
  27. target_link_libraries(check_types_builtin ${LIBS})
  28. add_test(types_builtin ${CMAKE_CURRENT_BINARY_DIR}/check_types_builtin)
  29. add_executable(check_types_memory check_types_memory.c $<TARGET_OBJECTS:open62541-object>)
  30. target_link_libraries(check_types_memory ${LIBS})
  31. add_test(types_memory ${CMAKE_CURRENT_BINARY_DIR}/check_types_memory)
  32. add_executable(check_types_range check_types_range.c $<TARGET_OBJECTS:open62541-object>)
  33. target_link_libraries(check_types_range ${LIBS})
  34. add_test(types_range ${CMAKE_CURRENT_BINARY_DIR}/check_types_range)
  35. add_executable(check_chunking check_chunking.c $<TARGET_OBJECTS:open62541-object>)
  36. target_link_libraries(check_chunking ${LIBS})
  37. add_test(chunking ${CMAKE_CURRENT_BINARY_DIR}/check_chunking)
  38. add_executable(check_services_view check_services_view.c $<TARGET_OBJECTS:open62541-object>)
  39. target_link_libraries(check_services_view ${LIBS})
  40. add_test(services_view ${CMAKE_CURRENT_BINARY_DIR}/check_services_view)
  41. add_executable(check_services_attributes check_services_attributes.c $<TARGET_OBJECTS:open62541-object>)
  42. target_link_libraries(check_services_attributes ${LIBS})
  43. add_test(services_attributes ${CMAKE_CURRENT_BINARY_DIR}/check_services_attributes)
  44. add_executable(check_services_nodemanagement check_services_nodemanagement.c $<TARGET_OBJECTS:open62541-object>)
  45. target_link_libraries(check_services_nodemanagement ${LIBS})
  46. add_test(services_nodemanagement ${CMAKE_CURRENT_BINARY_DIR}/check_services_nodemanagement)
  47. add_executable(check_services_subscriptions check_services_subscriptions.c $<TARGET_OBJECTS:open62541-object>)
  48. target_link_libraries(check_services_subscriptions ${LIBS})
  49. add_test(check_services_subscriptions ${CMAKE_CURRENT_BINARY_DIR}/check_services_subscriptions)
  50. add_executable(check_nodestore check_nodestore.c $<TARGET_OBJECTS:open62541-object>)
  51. target_link_libraries(check_nodestore ${LIBS})
  52. add_test(nodestore ${CMAKE_CURRENT_BINARY_DIR}/check_nodestore)
  53. add_executable(check_session check_session.c $<TARGET_OBJECTS:open62541-object>)
  54. target_link_libraries(check_session ${LIBS})
  55. add_test(session ${CMAKE_CURRENT_BINARY_DIR}/check_session)
  56. add_executable(check_server_jobs check_server_jobs.c $<TARGET_OBJECTS:open62541-object>)
  57. target_link_libraries(check_server_jobs ${LIBS})
  58. add_test(check_server_jobs ${CMAKE_CURRENT_BINARY_DIR}/check_server_jobs)
  59. add_executable(check_server_userspace check_server_userspace.c $<TARGET_OBJECTS:open62541-object>)
  60. target_link_libraries(check_server_userspace ${LIBS})
  61. add_test(check_server_userspace ${CMAKE_CURRENT_BINARY_DIR}/check_server_userspace)
  62. # test with canned interactions from files
  63. add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/client_HELOPN.bin
  64. ${CMAKE_CURRENT_BINARY_DIR}/client_CLO.bin
  65. ${CMAKE_CURRENT_BINARY_DIR}/client_CreateActivateSession.bin
  66. ${CMAKE_CURRENT_BINARY_DIR}/client_Browse.bin
  67. ${CMAKE_CURRENT_BINARY_DIR}/client_Read.bin
  68. ${CMAKE_CURRENT_BINARY_DIR}/client_Write.bin
  69. PRE_BUILD
  70. COMMAND python ${PROJECT_SOURCE_DIR}/tools/hex2bin.py
  71. ${CMAKE_CURRENT_SOURCE_DIR}/dumps/client_HELOPN.hex
  72. ${CMAKE_CURRENT_SOURCE_DIR}/dumps/client_CLO.hex
  73. ${CMAKE_CURRENT_SOURCE_DIR}/dumps/client_CreateActivateSession.hex
  74. ${CMAKE_CURRENT_SOURCE_DIR}/dumps/client_Browse.hex
  75. ${CMAKE_CURRENT_SOURCE_DIR}/dumps/client_Read.hex
  76. ${CMAKE_CURRENT_SOURCE_DIR}/dumps/client_Write.hex
  77. DEPENDS ${PROJECT_SOURCE_DIR}/tools/hex2bin.py
  78. ${CMAKE_CURRENT_SOURCE_DIR}/dumps/client_HELOPN.hex
  79. ${CMAKE_CURRENT_SOURCE_DIR}/dumps/client_CLO.hex
  80. ${CMAKE_CURRENT_SOURCE_DIR}/dumps/client_CreateActivateSession.hex
  81. ${CMAKE_CURRENT_SOURCE_DIR}/dumps/client_Browse.hex
  82. ${CMAKE_CURRENT_SOURCE_DIR}/dumps/client_Read.hex
  83. ${CMAKE_CURRENT_SOURCE_DIR}/dumps/client_Write.hex)
  84. add_custom_target(client_HELOPN.bin DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/client_HELOPN.bin")
  85. add_custom_target(client_CreateActivateSession.bin DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/client_CreateActivateSession.bin")
  86. add_executable(check_server_binary_messages check_server_binary_messages.c testing_networklayers.c $<TARGET_OBJECTS:open62541-object>)
  87. target_include_directories(check_server_binary_messages PRIVATE ${PROJECT_SOURCE_DIR}/src/server)
  88. target_link_libraries(check_server_binary_messages ${LIBS})
  89. add_dependencies(check_server_binary_messages client_HELOPN.bin)
  90. add_test(check_server_binary_messages_browse ${CMAKE_CURRENT_BINARY_DIR}/check_server_binary_messages
  91. ${CMAKE_CURRENT_BINARY_DIR}/client_HELOPN.bin
  92. ${CMAKE_CURRENT_BINARY_DIR}/client_CreateActivateSession.bin
  93. ${CMAKE_CURRENT_BINARY_DIR}/client_Browse.bin
  94. ${CMAKE_CURRENT_BINARY_DIR}/client_CLO.bin)
  95. add_test(check_server_binary_messages_read ${CMAKE_CURRENT_BINARY_DIR}/check_server_binary_messages
  96. ${CMAKE_CURRENT_BINARY_DIR}/client_HELOPN.bin
  97. ${CMAKE_CURRENT_BINARY_DIR}/client_CreateActivateSession.bin
  98. ${CMAKE_CURRENT_BINARY_DIR}/client_Read.bin
  99. ${CMAKE_CURRENT_BINARY_DIR}/client_CLO.bin)
  100. add_test(check_server_binary_messages_write ${CMAKE_CURRENT_BINARY_DIR}/check_server_binary_messages
  101. ${CMAKE_CURRENT_BINARY_DIR}/client_HELOPN.bin
  102. ${CMAKE_CURRENT_BINARY_DIR}/client_CreateActivateSession.bin
  103. ${CMAKE_CURRENT_BINARY_DIR}/client_Write.bin
  104. ${CMAKE_CURRENT_BINARY_DIR}/client_CLO.bin)
  105. add_executable(check_client check_client.c $<TARGET_OBJECTS:open62541-object>)
  106. target_link_libraries(check_client ${LIBS})
  107. add_test(check_client ${CMAKE_CURRENT_BINARY_DIR}/check_client)
  108. add_executable(check_client_subscriptions check_client_subscriptions.c $<TARGET_OBJECTS:open62541-object>)
  109. target_link_libraries(check_client_subscriptions ${LIBS})
  110. add_test(check_client_subscriptions ${CMAKE_CURRENT_BINARY_DIR}/check_client_subscriptions)
  111. add_executable(check_utils check_utils.c $<TARGET_OBJECTS:open62541-object>)
  112. target_link_libraries(check_utils ${LIBS})
  113. add_test(check_utils ${CMAKE_CURRENT_BINARY_DIR}/check_utils)