CMakeLists.txt 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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}) # contains open62541.h
  6. else()
  7. add_definitions(-DUA_NO_AMALGAMATION)
  8. endif()
  9. list(APPEND LIBS open62541 ${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)
  25. add_dependencies(tutorial_datatypes open625451_amalgamation)
  26. target_link_libraries(tutorial_datatypes ${LIBS})
  27. add_executable(tutorial_server_firststeps tutorial_server_firststeps.c)
  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)
  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)
  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)
  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)
  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)
  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)
  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)
  54. target_link_libraries(server ${LIBS})
  55. if(UA_ENABLE_NONSTANDARD_UDP)
  56. add_executable(server_udp server_udp.c ${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)
  63. target_link_libraries(client ${LIBS})
  64. ####################
  65. # Feature Examples #
  66. ####################
  67. add_executable(server_mainloop server_mainloop.c)
  68. target_link_libraries(server_mainloop ${LIBS})
  69. add_executable(server_instantiation server_instantiation.c)
  70. target_link_libraries(server_instantiation ${LIBS})
  71. add_executable(server_repeated_job server_repeated_job.c)
  72. target_link_libraries(server_repeated_job ${LIBS})
  73. add_executable(server_inheritance server_inheritance.c)
  74. target_link_libraries(server_inheritance ${LIBS})
  75. if(NOT BUILD_SHARED_LIBS AND UA_BUILD_EXAMPLES_NODESET_COMPILER)
  76. # needs internal methods which are not exported in the dynamic lib
  77. add_executable(server_nodeset server_nodeset.c ${PROJECT_BINARY_DIR}/src_generated/nodeset.c)
  78. target_link_libraries(server_nodeset ${LIBS})
  79. target_include_directories(server_nodeset PRIVATE ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/deps) # needs an internal header
  80. endif()
  81. if(UA_BUILD_SELFSIGNED_CERTIFICATE)
  82. find_package(OpenSSL REQUIRED)
  83. add_custom_command(OUTPUT server_cert.der ca.crt
  84. COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/certs/create_self-signed.py ${CMAKE_CURRENT_BINARY_DIR}
  85. DEPENDS ${PROJECT_SOURCE_DIR}/tools/certs/create_self-signed.py
  86. ${PROJECT_SOURCE_DIR}/tools/certs/localhost.cnf)
  87. add_custom_target(selfsigned ALL DEPENDS server_cert.der ca.crt)
  88. add_executable(server_certificate server_certificate.c server_cert.der ca.crt)
  89. target_link_libraries(server_certificate ${LIBS})
  90. endif()
  91. if(NOT BUILD_SHARED_LIBS)
  92. # needs internal methods which are not exported in the dynamic lib
  93. add_executable(server_readspeed server_readspeed.c)
  94. target_include_directories(server_readspeed PRIVATE ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/deps) # needs an internal header
  95. target_link_libraries(server_readspeed ${LIBS})
  96. endif()