CMakeLists.txt 4.9 KB

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