Skip to content

Commit 4d16565

Browse files
committed
Added C++20 coroutine broker.
1 parent 7b9b067 commit 4d16565

File tree

6 files changed

+3943
-19
lines changed

6 files changed

+3943
-19
lines changed

CHANGELOG.adoc

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
= History
44

55
== 10.0.1 (undetermined)
6+
* Added C++20 coroutine version of broker (experimental). #406
67
* Fixed connection status updating timing. #402
78
* Refined CI. #401
89
* Refined log level. #399, #402

tool/CMakeLists.txt

+50-18
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ list(APPEND exec_PROGRAMS
44
client_cli.cpp
55
)
66

7+
if("cxx_std_20" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
8+
set(CMAKE_CXX_STANDARD 20)
9+
message(STATUS "C++20 tools added")
10+
list(APPEND exec_PROGRAMS
11+
cpp20coro_broker.cpp
12+
)
13+
endif()
14+
715
find_package(Boost 1.82.0 REQUIRED COMPONENTS program_options)
816

917
# Without this setting added, azure pipelines completely fails to find the boost libraries. No idea why.
@@ -58,29 +66,53 @@ endforeach()
5866

5967
# Separate compiled broker
6068
if(ASYNC_MQTT_BUILD_LIB)
61-
62-
add_executable(broker_separate broker.cpp)
63-
add_dependencies(broker_separate async_mqtt_asio_bind async_mqtt_protocol)
64-
target_compile_definitions(broker_separate PRIVATE ASYNC_MQTT_SEPARATE_COMPILATION)
65-
target_include_directories(broker_separate PRIVATE include ${Boost_INCLUDE_DIRS})
66-
target_link_libraries(broker_separate async_mqtt_iface async_mqtt_asio_bind async_mqtt_protocol)
67-
if(ASYNC_MQTT_USE_LOG)
69+
add_executable(broker_separate broker.cpp)
70+
add_dependencies(broker_separate async_mqtt_asio_bind async_mqtt_protocol)
71+
target_compile_definitions(broker_separate PRIVATE ASYNC_MQTT_SEPARATE_COMPILATION)
72+
target_include_directories(broker_separate PRIVATE include ${Boost_INCLUDE_DIRS})
73+
target_link_libraries(broker_separate async_mqtt_iface async_mqtt_asio_bind async_mqtt_protocol)
74+
if(ASYNC_MQTT_USE_LOG)
75+
target_compile_definitions(
76+
broker_separate
77+
PUBLIC
78+
$<IF:$<BOOL:${ASYNC_MQTT_USE_STATIC_BOOST}>,,BOOST_LOG_DYN_LINK>
79+
)
80+
target_link_libraries(
81+
broker_separate Boost::log
82+
)
83+
endif()
6884
target_compile_definitions(
6985
broker_separate
7086
PUBLIC
71-
$<IF:$<BOOL:${ASYNC_MQTT_USE_STATIC_BOOST}>,,BOOST_LOG_DYN_LINK>
72-
)
73-
target_link_libraries(
74-
broker_separate Boost::log
87+
$<IF:$<BOOL:${ASYNC_MQTT_USE_STATIC_BOOST}>,,BOOST_PROGRAM_OPTIONS_DYN_LINK>
7588
)
76-
endif()
77-
target_compile_definitions(
78-
broker_separate
79-
PUBLIC
80-
$<IF:$<BOOL:${ASYNC_MQTT_USE_STATIC_BOOST}>,,BOOST_PROGRAM_OPTIONS_DYN_LINK>
81-
)
82-
target_link_libraries(broker_separate Boost::program_options)
89+
target_link_libraries(broker_separate Boost::program_options)
8390

91+
if("cxx_std_20" IN_LIST CMAKE_CXX_COMPILE_FEATURES)
92+
set(CMAKE_CXX_STANDARD 20)
93+
message(STATUS "C++20 separate broker added")
94+
add_executable(cpp20coro_broker_separate cpp20coro_broker.cpp)
95+
add_dependencies(cpp20coro_broker_separate async_mqtt_asio_bind async_mqtt_protocol)
96+
target_compile_definitions(cpp20coro_broker_separate PRIVATE ASYNC_MQTT_SEPARATE_COMPILATION)
97+
target_include_directories(cpp20coro_broker_separate PRIVATE include ${Boost_INCLUDE_DIRS})
98+
target_link_libraries(cpp20coro_broker_separate async_mqtt_iface async_mqtt_asio_bind async_mqtt_protocol)
99+
if(ASYNC_MQTT_USE_LOG)
100+
target_compile_definitions(
101+
cpp20coro_broker_separate
102+
PUBLIC
103+
$<IF:$<BOOL:${ASYNC_MQTT_USE_STATIC_BOOST}>,,BOOST_LOG_DYN_LINK>
104+
)
105+
target_link_libraries(
106+
cpp20coro_broker_separate Boost::log
107+
)
108+
endif()
109+
target_compile_definitions(
110+
cpp20coro_broker_separate
111+
PUBLIC
112+
$<IF:$<BOOL:${ASYNC_MQTT_USE_STATIC_BOOST}>,,BOOST_PROGRAM_OPTIONS_DYN_LINK>
113+
)
114+
target_link_libraries(cpp20coro_broker_separate Boost::program_options)
115+
endif()
84116
endif()
85117

86118
if(UNIX)

0 commit comments

Comments
 (0)