CMakeLists.txt 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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})
  10. target_link_libraries(${EXAMPLE_NAME} open62541 ${open62541_LIBRARIES})
  11. assign_source_group(${EXAMPLE_SOURCE})
  12. add_dependencies(${EXAMPLE_NAME} open62541_amalgamation)
  13. set_target_properties(${EXAMPLE_NAME} PROPERTIES FOLDER "open62541/examples")
  14. if(UA_COMPILE_AS_CXX)
  15. set_source_files_properties(${EXAMPLE_SOURCE} PROPERTIES LANGUAGE CXX)
  16. endif()
  17. endmacro()
  18. #############
  19. # Tutorials #
  20. #############
  21. add_example(tutorial_datatypes tutorial_datatypes.c)
  22. add_example(tutorial_server_firststeps tutorial_server_firststeps.c)
  23. add_example(tutorial_server_variable tutorial_server_variable.c)
  24. add_example(tutorial_server_datasource tutorial_server_datasource.c)
  25. add_example(tutorial_server_variabletype tutorial_server_variabletype.c)
  26. add_example(tutorial_server_object tutorial_server_object.c)
  27. if(UA_ENABLE_METHODCALLS)
  28. add_example(tutorial_server_method tutorial_server_method.c)
  29. endif()
  30. add_example(tutorial_client_firststeps tutorial_client_firststeps.c)
  31. ##################
  32. # Example Server #
  33. ##################
  34. add_example(server server.c)
  35. ##################
  36. # Example Client #
  37. ##################
  38. add_example(client client.c)
  39. ####################
  40. # Feature Examples #
  41. ####################
  42. add_example(server_mainloop server_mainloop.c)
  43. add_example(server_instantiation server_instantiation.c)
  44. add_example(server_repeated_job server_repeated_job.c)
  45. add_example(server_inheritance server_inheritance.c)
  46. if(NOT BUILD_SHARED_LIBS AND UA_BUILD_EXAMPLES_NODESET_COMPILER)
  47. # needs internal methods which are not exported in the dynamic lib
  48. add_example(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_BUILD_SELFSIGNED_CERTIFICATE)
  52. find_package(OpenSSL REQUIRED)
  53. add_custom_command(OUTPUT server_cert.der ca.crt
  54. COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/certs/create_self-signed.py ${CMAKE_CURRENT_BINARY_DIR}
  55. DEPENDS ${PROJECT_SOURCE_DIR}/tools/certs/create_self-signed.py
  56. ${PROJECT_SOURCE_DIR}/tools/certs/localhost.cnf)
  57. add_custom_target(selfsigned ALL DEPENDS server_cert.der ca.crt)
  58. add_executable(server_certificate server_certificate.c ${STATIC_OBJECTS} server_cert.der ca.crt)
  59. target_link_libraries(server_certificate ${LIBS})
  60. endif()
  61. if(UA_ENABLE_DISCOVERY)
  62. add_example(discovery_server_lds discovery/server_lds.c)
  63. add_example(discovery_server_register discovery/server_register.c)
  64. add_example(discovery_client_find_servers discovery/client_find_servers.c)
  65. if(UA_ENABLE_DISCOVERY_MULTICAST)
  66. add_example(discovery_server_multicast discovery/server_multicast.c)
  67. endif()
  68. endif()