CMakeLists.txt 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. set(STATIC_OBJECTS $<TARGET_OBJECTS:open62541-object>)
  22. if(WIN32 AND BUILD_SHARED_LIBS)
  23. # on windows the .dll.a file has to be used for the linker
  24. list(APPEND LIBS open62541)
  25. set(STATIC_OBJECTS "")
  26. endif()
  27. #############
  28. # Tutorials #
  29. #############
  30. add_executable(tutorial_datatypes tutorial_datatypes.c ${STATIC_OBJECTS})
  31. add_dependencies(tutorial_datatypes open625451_amalgamation)
  32. target_link_libraries(tutorial_datatypes ${LIBS})
  33. add_executable(tutorial_server_firststeps tutorial_server_firststeps.c ${STATIC_OBJECTS})
  34. add_dependencies(tutorial_server_firststeps open625451_amalgamation)
  35. target_link_libraries(tutorial_server_firststeps ${LIBS})
  36. add_executable(tutorial_server_variable tutorial_server_variable.c ${STATIC_OBJECTS})
  37. add_dependencies(tutorial_server_variable open625451_amalgamation)
  38. target_link_libraries(tutorial_server_variable ${LIBS})
  39. add_executable(tutorial_server_datasource tutorial_server_datasource.c ${STATIC_OBJECTS})
  40. add_dependencies(tutorial_server_datasource open625451_amalgamation)
  41. target_link_libraries(tutorial_server_datasource ${LIBS})
  42. add_executable(tutorial_server_variabletype tutorial_server_variabletype.c ${STATIC_OBJECTS})
  43. add_dependencies(tutorial_server_variabletype open625451_amalgamation)
  44. target_link_libraries(tutorial_server_variabletype ${LIBS})
  45. add_executable(tutorial_server_object tutorial_server_object.c ${STATIC_OBJECTS})
  46. add_dependencies(tutorial_server_object open625451_amalgamation)
  47. target_link_libraries(tutorial_server_object ${LIBS})
  48. if(UA_ENABLE_METHODCALLS)
  49. add_executable(tutorial_server_method tutorial_server_method.c ${STATIC_OBJECTS})
  50. add_dependencies(tutorial_server_method open625451_amalgamation)
  51. target_link_libraries(tutorial_server_method ${LIBS})
  52. endif()
  53. add_executable(tutorial_client_firststeps tutorial_client_firststeps.c ${STATIC_OBJECTS})
  54. add_dependencies(tutorial_client_firststeps open625451_amalgamation)
  55. target_link_libraries(tutorial_client_firststeps ${LIBS})
  56. ##################
  57. # Example Server #
  58. ##################
  59. add_executable(server server.c ${STATIC_OBJECTS})
  60. target_link_libraries(server ${LIBS})
  61. if(UA_ENABLE_NONSTANDARD_UDP)
  62. add_executable(server_udp server_udp.c ${STATIC_OBJECTS} ${PROJECT_SOURCE_DIR}/plugins/ua_network_udp.c)
  63. target_link_libraries(server_udp ${LIBS})
  64. endif()
  65. ##################
  66. # Example Client #
  67. ##################
  68. add_executable(client client.c ${STATIC_OBJECTS})
  69. target_link_libraries(client ${LIBS})
  70. ####################
  71. # Feature Examples #
  72. ####################
  73. add_executable(server_mainloop server_mainloop.c ${STATIC_OBJECTS})
  74. target_link_libraries(server_mainloop ${LIBS})
  75. add_executable(server_instantiation server_instantiation.c ${STATIC_OBJECTS})
  76. target_link_libraries(server_instantiation ${LIBS})
  77. add_executable(server_repeated_job server_repeated_job.c ${STATIC_OBJECTS})
  78. target_link_libraries(server_repeated_job ${LIBS})
  79. add_executable(server_inheritance server_inheritance.c ${STATIC_OBJECTS})
  80. target_link_libraries(server_inheritance ${LIBS})
  81. if(NOT BUILD_SHARED_LIBS AND UA_BUILD_EXAMPLES_NODESET_COMPILER)
  82. # needs internal methods which are not exported in the dynamic lib
  83. add_executable(server_nodeset server_nodeset.c ${PROJECT_BINARY_DIR}/src_generated/nodeset.c ${STATIC_OBJECTS})
  84. target_link_libraries(server_nodeset ${LIBS})
  85. target_include_directories(server_nodeset PRIVATE ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/deps) # needs an internal header
  86. endif()
  87. if(UA_BUILD_SELFSIGNED_CERTIFICATE)
  88. find_package(OpenSSL REQUIRED)
  89. add_custom_command(OUTPUT server_cert.der ca.crt
  90. COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/certs/create_self-signed.py ${CMAKE_CURRENT_BINARY_DIR}
  91. DEPENDS ${PROJECT_SOURCE_DIR}/tools/certs/create_self-signed.py
  92. ${PROJECT_SOURCE_DIR}/tools/certs/localhost.cnf)
  93. add_custom_target(selfsigned ALL DEPENDS server_cert.der ca.crt)
  94. add_executable(server_certificate server_certificate.c ${STATIC_OBJECTS} server_cert.der ca.crt)
  95. target_link_libraries(server_certificate ${LIBS})
  96. endif()
  97. if(NOT BUILD_SHARED_LIBS)
  98. # needs internal methods which are not exported in the dynamic lib
  99. add_executable(server_readspeed server_readspeed.c ${STATIC_OBJECTS})
  100. target_include_directories(server_readspeed PRIVATE ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/deps) # needs an internal header
  101. target_link_libraries(server_readspeed ${LIBS})
  102. endif()