CMakeLists.txt 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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})
  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. macro(add_example EXAMPLE_NAME EXAMPLE_SOURCE)
  21. add_executable(${EXAMPLE_NAME} $<TARGET_OBJECTS:open62541-object> ${EXAMPLE_SOURCE})
  22. target_link_libraries(${EXAMPLE_NAME} ${LIBS})
  23. if(UA_COMPILE_AS_CXX)
  24. set_source_files_properties(${EXAMPLE_SOURCE} PROPERTIES LANGUAGE CXX)
  25. endif()
  26. endmacro()
  27. ##################
  28. # Example Server #
  29. ##################
  30. add_example(server server.c)
  31. ##################
  32. # Example Client #
  33. ##################
  34. add_example(client client.c)
  35. ####################
  36. # Feature Examples #
  37. ####################
  38. add_example(server_variable server_variable.c)
  39. add_example(server_mainloop server_mainloop.c)
  40. add_example(server_datasource server_datasource.c)
  41. add_example(server_firstSteps server_firstSteps.c)
  42. add_example(server_instantiation server_instantiation.c)
  43. add_example(server_repeated_job server_repeated_job.c)
  44. add_example(server_readspeed server_readspeed.c)
  45. target_include_directories(server_readspeed PRIVATE ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/deps) # needs an internal header
  46. add_example(server_inheritance server_inheritance.c)
  47. if(UA_BUILD_EXAMPLES_NODESET_COMPILER)
  48. add_executable(server_nodeset "server_nodeset.c ${PROJECT_BINARY_DIR}/src_generated/nodeset.c")
  49. target_include_directories(server_nodeset PRIVATE ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/deps) # needs an internal header
  50. endif()
  51. if(UA_ENABLE_METHODCALLS)
  52. add_example(server_method server_method.c)
  53. endif()
  54. if(UA_BUILD_SELFSIGNED_CERTIFICATE)
  55. find_package(OpenSSL REQUIRED)
  56. add_custom_command(OUTPUT server_cert.der ca.crt
  57. COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/certs/create_self-signed.py ${CMAKE_CURRENT_BINARY_DIR}
  58. DEPENDS ${PROJECT_SOURCE_DIR}/tools/certs/create_self-signed.py
  59. ${PROJECT_SOURCE_DIR}/tools/certs/localhost.cnf)
  60. add_custom_target(selfsigned ALL DEPENDS server_cert.der ca.crt)
  61. add_executable(server_certificate server_certificate.c $<TARGET_OBJECTS:open62541-object> server_cert.der ca.crt)
  62. target_link_libraries(server_certificate ${LIBS})
  63. endif()
  64. if(UA_ENABLE_DISCOVERY)
  65. add_example(discovery_server_discovery discovery/server_discovery.c)
  66. add_example(discovery_server_register discovery/server_register.c)
  67. add_example(discovery_client_find_servers discovery/client_find_servers.c)
  68. endif()
  69. add_example(client_firstSteps client_firstSteps.c)