CMakeLists.txt modifications

This commit is contained in:
Korina Šimičević
2024-01-03 14:54:25 +01:00
committed by Ivica Siladić
parent 6abe93fcc9
commit 6f5c179929
5 changed files with 45 additions and 41 deletions

View File

@ -5,30 +5,27 @@ project(async-mqtt5-examples CXX)
include(../cmake/project-is-top-level.cmake)
if(PROJECT_IS_TOP_LEVEL)
find_package(async_mqtt5 REQUIRED)
find_package(async-mqtt5 REQUIRED)
endif()
function(add_example name)
add_executable("${name}" ${ARGN})
target_compile_features("${name}" PRIVATE cxx_std_20)
target_compile_features("${name}" PRIVATE cxx_std_20) # for coroutines
target_link_libraries("${name}" PRIVATE Async::MQTT5)
endfunction()
foreach(f callbacks cpp20_coroutines futures publisher receiver)
add_example("${f}" "${f}.cpp")
endforeach()
foreach(f publisher receiver)
add_example("${f}" "${f}.cpp")
endforeach()
#[[
add_example(
misc
src/run_examples.cpp
network_connection.cpp
openssl-tls.cpp
set(EXAMPLES
tcp.cpp
websocket-tcp.cpp
websocket-tls.cpp
openssl_tls.cpp
websocket_tcp.cpp
websocket_tls.cpp
)
find_package(OpenSSL REQUIRED)
target_link_libraries(misc PRIVATE OpenSSL::SSL)
]]
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)