CMakeLists.txt 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. include_directories(${PROJECT_SOURCE_DIR}/include)
  2. include_directories(${PROJECT_SOURCE_DIR}/plugins)
  3. include_directories(${PROJECT_BINARY_DIR})
  4. #############################
  5. # Compiled binaries folders #
  6. #############################
  7. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/examples)
  8. macro(add_example EXAMPLE_NAME EXAMPLE_SOURCE)
  9. add_executable(${EXAMPLE_NAME} ${STATIC_OBJECTS} ${EXAMPLE_SOURCE} ${ARGN})
  10. target_link_libraries(${EXAMPLE_NAME} open62541 ${open62541_LIBRARIES})
  11. assign_source_group(${EXAMPLE_SOURCE})
  12. add_dependencies(${EXAMPLE_NAME} open62541-amalgamation-header open62541-amalgamation-source)
  13. set_target_properties(${EXAMPLE_NAME} PROPERTIES FOLDER "open62541/examples")
  14. set_target_properties(${EXAMPLE_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
  15. if(UA_COMPILE_AS_CXX)
  16. set_source_files_properties(${EXAMPLE_SOURCE} PROPERTIES LANGUAGE CXX)
  17. endif()
  18. endmacro()
  19. #############
  20. # Tutorials #
  21. #############
  22. add_example(tutorial_datatypes tutorial_datatypes.c)
  23. add_example(tutorial_server_firststeps tutorial_server_firststeps.c)
  24. add_example(tutorial_server_variable tutorial_server_variable.c)
  25. add_example(tutorial_server_datasource tutorial_server_datasource.c)
  26. add_example(tutorial_server_variabletype tutorial_server_variabletype.c)
  27. add_example(tutorial_server_object tutorial_server_object.c)
  28. if(UA_ENABLE_METHODCALLS)
  29. add_example(tutorial_server_method tutorial_server_method.c)
  30. endif()
  31. add_example(tutorial_client_firststeps tutorial_client_firststeps.c)
  32. add_example(tutorial_client_events tutorial_client_events.c)
  33. ##################
  34. # Example Server #
  35. ##################
  36. add_example(server server.c)
  37. ##################
  38. # Example Client #
  39. ##################
  40. add_example(client client.c)
  41. add_example(client_connect_loop client_connect_loop.c)
  42. if(UA_ENABLE_SUBSCRIPTIONS)
  43. add_example(client_subscription_loop client_subscription_loop.c)
  44. endif()
  45. ####################
  46. # Feature Examples #
  47. ####################
  48. add_example(server_mainloop server_mainloop.c)
  49. add_example(server_instantiation server_instantiation.c)
  50. add_example(server_repeated_job server_repeated_job.c)
  51. add_example(server_inheritance server_inheritance.c)
  52. if(UA_ENABLE_ENCRYPTION)
  53. add_example(server_basic128rsa15 encryption/server_basic128rsa15.c)
  54. endif()
  55. add_example(custom_datatype_client custom_datatype/client_types_custom.c)
  56. add_example(custom_datatype_server custom_datatype/server_types_custom.c)
  57. if(UA_ENABLE_NODEMANAGEMENT)
  58. add_example(access_control_server access_control/server_access_control.c)
  59. add_example(access_control_client access_control/client_access_control.c)
  60. endif()
  61. if(UA_BUILD_SELFSIGNED_CERTIFICATE)
  62. find_package(OpenSSL REQUIRED)
  63. add_custom_command(OUTPUT server_cert.der ca.crt
  64. COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/certs/create_self-signed.py ${CMAKE_CURRENT_BINARY_DIR}
  65. DEPENDS ${PROJECT_SOURCE_DIR}/tools/certs/create_self-signed.py
  66. ${PROJECT_SOURCE_DIR}/tools/certs/localhost.cnf)
  67. add_custom_target(selfsigned ALL DEPENDS server_cert.der ca.crt)
  68. add_executable(server_certificate server_certificate.c ${STATIC_OBJECTS} server_cert.der ca.crt)
  69. target_link_libraries(server_certificate open62541 ${open62541_LIBRARIES})
  70. endif()
  71. if(UA_ENABLE_DISCOVERY)
  72. add_example(discovery_server_lds discovery/server_lds.c)
  73. add_example(discovery_server_register discovery/server_register.c)
  74. add_example(discovery_client_find_servers discovery/client_find_servers.c)
  75. if(UA_ENABLE_DISCOVERY_MULTICAST)
  76. add_example(discovery_server_multicast discovery/server_multicast.c)
  77. endif()
  78. endif()
  79. add_subdirectory(nodeset)