2023-11-29 00:48:21 +01:00
|
|
|
cmake_minimum_required(VERSION 3.15)
|
|
|
|
|
|
|
|
|
|
project(async-mqtt5-examples CXX)
|
|
|
|
|
|
|
|
|
|
include(../cmake/project-is-top-level.cmake)
|
|
|
|
|
|
|
|
|
|
if(PROJECT_IS_TOP_LEVEL)
|
2024-01-03 14:54:25 +01:00
|
|
|
find_package(async-mqtt5 REQUIRED)
|
2023-11-29 00:48:21 +01:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
function(add_example name)
|
|
|
|
|
add_executable("${name}" ${ARGN})
|
2024-01-03 14:54:25 +01:00
|
|
|
target_compile_features("${name}" PRIVATE cxx_std_20) # for coroutines
|
2023-11-29 00:48:21 +01:00
|
|
|
target_link_libraries("${name}" PRIVATE Async::MQTT5)
|
|
|
|
|
endfunction()
|
|
|
|
|
|
2024-01-03 14:54:25 +01:00
|
|
|
foreach(f publisher receiver)
|
|
|
|
|
add_example("${f}" "${f}.cpp")
|
|
|
|
|
endforeach()
|
2023-11-29 00:48:21 +01:00
|
|
|
|
2024-01-03 14:54:25 +01:00
|
|
|
set(EXAMPLES
|
2023-11-29 00:48:21 +01:00
|
|
|
tcp.cpp
|
2024-01-03 14:54:25 +01:00
|
|
|
openssl_tls.cpp
|
|
|
|
|
websocket_tcp.cpp
|
|
|
|
|
websocket_tls.cpp
|
2023-11-29 00:48:21 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
find_package(OpenSSL REQUIRED)
|
2024-01-03 14:54:25 +01:00
|
|
|
add_executable(examples src/run_examples.cpp ${EXAMPLES})
|
|
|
|
|
target_compile_features(examples PRIVATE cxx_std_17)
|
|
|
|
|
target_link_libraries(examples PRIVATE Async::MQTT5 OpenSSL::SSL)
|