Files
boost_mqtt5/example/CMakeLists.txt
T
Korina Šimičević 9a6788c913 Examples rework
Summary:
related to T15261, T15262
- all examples are added to CI checks
	- as a result, CMakeLists.txt in example folder is reworked to build all examples instead of one
	- also removed chapter Building with CMake temporarily (it will be back)
- all examples accept runtime arguments (brokers, port, clientid) (default: hivemq public broker)
- implemented example suggestions by R.Perez, most notable:
	- all examples include mqtt headers they use (no more unified headers)
	- multithreaded examples use thread_pool instead of asio::io_context
- all examples use logger with log_level::info by default

Reviewers: ivica

Reviewed By: ivica

Subscribers: iljazovic, miljen

Differential Revision: https://repo.mireo.local/D32602
2024-12-04 09:45:18 +01:00

28 lines
683 B
CMake

cmake_minimum_required(VERSION 3.15)
project(async-mqtt5-examples CXX)
include(../cmake/project-is-top-level.cmake)
if(PROJECT_IS_TOP_LEVEL)
find_package(async-mqtt5 REQUIRED)
endif()
function(add_example name)
add_executable("${name}" ${ARGN})
target_link_libraries("${name}" PRIVATE Async::MQTT5)
string(FIND "${example_name}" "tls" found_tls)
if(found_tls GREATER -1)
target_link_libraries("${name}" PRIVATE OpenSSL::SSL)
endif()
endfunction()
file(GLOB examples "*.cpp")
foreach(file_path ${examples})
get_filename_component(example_name "${file_path}" NAME_WE)
add_example("${example_name}" "${file_path}")
endforeach()
find_package(OpenSSL REQUIRED)