CMakeLists.txt 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. find_package(Check REQUIRED)
  7. find_package(Threads REQUIRED)
  8. set(LIBS ${CHECK_LIBRARIES} ${open62541_LIBRARIES})
  9. if(NOT WIN32)
  10. list(APPEND LIBS pthread m)
  11. if (NOT APPLE)
  12. list(APPEND LIBS rt subunit)
  13. endif()
  14. else()
  15. list(APPEND LIBS ws2_32)
  16. endif()
  17. if(UA_ENABLE_MULTITHREADING)
  18. list(APPEND LIBS urcu-cds urcu urcu-common)
  19. endif()
  20. add_definitions(-Wno-sign-conversion)
  21. # the unit test are built directly on the open62541 object files. so they can
  22. # access symbols that are hidden/not exported to the shared library
  23. add_executable(check_builtin check_builtin.c $<TARGET_OBJECTS:open62541-object>)
  24. target_link_libraries(check_builtin ${LIBS})
  25. add_test(builtin ${CMAKE_CURRENT_BINARY_DIR}/check_builtin)
  26. add_executable(check_memory check_memory.c $<TARGET_OBJECTS:open62541-object>)
  27. target_link_libraries(check_memory ${LIBS})
  28. add_test(memory ${CMAKE_CURRENT_BINARY_DIR}/check_memory)
  29. # add_executable(check_stack check_stack.c)
  30. # target_link_libraries(check_stack ${LIBS})
  31. # add_test(stack ${CMAKE_CURRENT_BINARY_DIR}/check_stack)
  32. add_executable(check_services_view check_services_view.c $<TARGET_OBJECTS:open62541-object>)
  33. target_link_libraries(check_services_view ${LIBS})
  34. add_test(services_view ${CMAKE_CURRENT_BINARY_DIR}/check_services_view)
  35. add_executable(check_services_attributes check_services_attributes.c $<TARGET_OBJECTS:open62541-object>)
  36. target_link_libraries(check_services_attributes ${LIBS})
  37. add_test(services_attributes ${CMAKE_CURRENT_BINARY_DIR}/check_services_attributes)
  38. add_executable(check_services_nodemanagement check_services_nodemanagement.c $<TARGET_OBJECTS:open62541-object>)
  39. target_link_libraries(check_services_nodemanagement ${LIBS})
  40. add_test(services_nodemanagement ${CMAKE_CURRENT_BINARY_DIR}/check_services_nodemanagement)
  41. add_executable(check_nodestore check_nodestore.c $<TARGET_OBJECTS:open62541-object>)
  42. target_link_libraries(check_nodestore ${LIBS})
  43. add_test(nodestore ${CMAKE_CURRENT_BINARY_DIR}/check_nodestore)
  44. add_executable(check_session check_session.c $<TARGET_OBJECTS:open62541-object>)
  45. target_link_libraries(check_session ${LIBS})
  46. add_test(session ${CMAKE_CURRENT_BINARY_DIR}/check_session)
  47. add_executable(check_server_userspace check_server_userspace.c $<TARGET_OBJECTS:open62541-object>)
  48. target_link_libraries(check_server_userspace ${LIBS})
  49. add_test(check_server_userspace ${CMAKE_CURRENT_BINARY_DIR}/check_server_userspace)
  50. # add_executable(check_startup check_startup.c)
  51. # target_link_libraries(check_startup ${LIBS})
  52. # add_test(startup ${CMAKE_CURRENT_BINARY_DIR}/check_startup)
  53. # test with canned interactions from files
  54. add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/client_HELOPN.bin
  55. ${CMAKE_CURRENT_BINARY_DIR}/client_CreateActivateSession.bin
  56. PRE_BUILD
  57. COMMAND python ${PROJECT_SOURCE_DIR}/tools/hex2bin.py
  58. ${CMAKE_CURRENT_SOURCE_DIR}/dumps/client_HELOPN.hex
  59. ${CMAKE_CURRENT_SOURCE_DIR}/dumps/client_CreateActivateSession.hex
  60. DEPENDS ${PROJECT_SOURCE_DIR}/tools/hex2bin.py
  61. ${CMAKE_CURRENT_SOURCE_DIR}/dumps/client_HELOPN.hex
  62. ${CMAKE_CURRENT_SOURCE_DIR}/dumps/client_CreateActivateSession.hex)
  63. add_custom_target(client_HELOPN.bin DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/client_HELOPN.bin")
  64. add_custom_target(client_CreateActivateSession.bin DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/client_CreateActivateSession.bin")
  65. add_executable(check_server_binary_messages check_server_binary_messages.c testing_networklayers.c $<TARGET_OBJECTS:open62541-object>)
  66. target_include_directories(check_server_binary_messages PRIVATE ${PROJECT_SOURCE_DIR}/src/server)
  67. target_link_libraries(check_server_binary_messages ${LIBS})
  68. add_dependencies(check_server_binary_messages client_HELOPN.bin)
  69. add_test(check_server_binary_messages_helopn ${CMAKE_CURRENT_BINARY_DIR}/check_server_binary_messages
  70. ${CMAKE_CURRENT_BINARY_DIR}/client_HELOPN.bin)
  71. add_test(check_server_binary_messages_activate_session ${CMAKE_CURRENT_BINARY_DIR}/check_server_binary_messages
  72. ${CMAKE_CURRENT_BINARY_DIR}/client_HELOPN.bin
  73. ${CMAKE_CURRENT_BINARY_DIR}/client_CreateActivateSession.bin)