CMakeLists.txt 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. include_directories(${PROJECT_SOURCE_DIR}/include)
  2. include_directories(${PROJECT_SOURCE_DIR}/plugins)
  3. if(UA_ENABLE_AMALGAMATION)
  4. include_directories(${PROJECT_BINARY_DIR}) # contain open62541.h
  5. else()
  6. add_definitions(-DUA_NO_AMALGAMATION)
  7. endif()
  8. list(APPEND LIBS ${open62541_LIBRARIES} open62541)
  9. if(NOT WIN32)
  10. list(APPEND LIBS pthread)
  11. if (NOT APPLE)
  12. list(APPEND LIBS rt)
  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(UA_ENABLE_MULTITHREADING)
  20. ##################
  21. # Example Server #
  22. ##################
  23. add_executable(server server.c $<TARGET_OBJECTS:open62541-object>)
  24. target_link_libraries(server ${LIBS})
  25. if(UA_ENABLE_NONSTANDARD_UDP)
  26. add_executable(server_udp server_udp.c $<TARGET_OBJECTS:open62541-object> ${PROJECT_SOURCE_DIR}/plugins/ua_network_udp.c)
  27. target_link_libraries(server_udp ${LIBS})
  28. endif()
  29. ##################
  30. # Example Client #
  31. ##################
  32. add_executable(client client.c $<TARGET_OBJECTS:open62541-object>)
  33. target_link_libraries(client ${LIBS})
  34. ####################
  35. # Feature Examples #
  36. ####################
  37. add_executable(server_variable server_variable.c $<TARGET_OBJECTS:open62541-object>)
  38. target_link_libraries(server_variable ${LIBS})
  39. add_executable(server_mainloop server_mainloop.c $<TARGET_OBJECTS:open62541-object>)
  40. target_link_libraries(server_mainloop ${LIBS})
  41. add_executable(server_datasource server_datasource.c $<TARGET_OBJECTS:open62541-object>)
  42. target_link_libraries(server_datasource ${LIBS})
  43. add_executable(server_firstSteps server_firstSteps.c $<TARGET_OBJECTS:open62541-object>)
  44. target_link_libraries(server_firstSteps ${LIBS})
  45. add_executable(server_instantiation server_instantiation.c $<TARGET_OBJECTS:open62541-object>)
  46. target_link_libraries(server_instantiation ${LIBS})
  47. add_executable(server_repeated_job server_repeated_job.c $<TARGET_OBJECTS:open62541-object>)
  48. target_link_libraries(server_repeated_job ${LIBS})
  49. add_executable(server_readspeed server_readspeed.c $<TARGET_OBJECTS:open62541-object>)
  50. target_include_directories(server_readspeed PRIVATE ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/deps) # needs an internal header
  51. target_link_libraries(server_readspeed ${LIBS})
  52. add_executable(server_inheritance server_inheritance.c $<TARGET_OBJECTS:open62541-object>)
  53. target_link_libraries(server_inheritance ${LIBS})
  54. if(UA_BUILD_EXAMPLES_NODESET_COMPILER)
  55. add_executable(server_nodeset server_nodeset.c ${PROJECT_BINARY_DIR}/src_generated/nodeset.c $<TARGET_OBJECTS:open62541-object>)
  56. target_link_libraries(server_nodeset ${LIBS})
  57. target_include_directories(server_nodeset PRIVATE ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/deps) # needs an internal header
  58. endif()
  59. if(UA_ENABLE_METHODCALLS)
  60. add_executable(server_method server_method.c $<TARGET_OBJECTS:open62541-object>)
  61. target_link_libraries(server_method ${LIBS})
  62. endif()
  63. if(UA_BUILD_SELFSIGNED_CERTIFICATE)
  64. find_package(OpenSSL REQUIRED)
  65. add_custom_command(OUTPUT server_cert.der ca.crt
  66. COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/certs/create_self-signed.py ${CMAKE_CURRENT_BINARY_DIR}
  67. DEPENDS ${PROJECT_SOURCE_DIR}/tools/certs/create_self-signed.py
  68. ${PROJECT_SOURCE_DIR}/tools/certs/localhost.cnf)
  69. add_custom_target(selfsigned ALL DEPENDS server_cert.der ca.crt)
  70. add_executable(server_certificate server_certificate.c $<TARGET_OBJECTS:open62541-object> server_cert.der ca.crt)
  71. target_link_libraries(server_certificate ${LIBS})
  72. endif()
  73. if(UA_ENABLE_DISCOVERY)
  74. add_executable(discovery_server_discovery discovery/server_discovery.c)
  75. target_link_libraries(discovery_server_discovery ${LIBS})
  76. add_executable(discovery_server_register discovery/server_register.c)
  77. target_link_libraries(discovery_server_register ${LIBS})
  78. add_executable(discovery_client_find_servers discovery/client_find_servers.c)
  79. target_link_libraries(discovery_client_find_servers ${LIBS})
  80. endif()
  81. add_executable(client_firstSteps client_firstSteps.c $<TARGET_OBJECTS:open62541-object>)
  82. target_link_libraries(client_firstSteps ${LIBS})