Skip to content

Commit 0cd2f0e

Browse files
committed
Update DelegateMQ library
1 parent 6ec0fa8 commit 0cd2f0e

File tree

9 files changed

+612
-303
lines changed

9 files changed

+612
-303
lines changed

DelegateMQ/DelegateMQ.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
#include "delegate/DelegateOpt.h"
5858
#include "delegate/MulticastDelegateSafe.h"
5959
#include "delegate/UnicastDelegateSafe.h"
60+
#include "delegate/SignalSafe.h"
6061
#include "delegate/DelegateAsync.h"
6162
#include "delegate/DelegateAsyncWait.h"
6263
#include "delegate/DelegateRemote.h"

DelegateMQ/External.cmake

Lines changed: 75 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,123 @@
1-
# External library definitions to support remote delegates. Update the options
2-
# below based on the target build platform.
1+
include(CMakeFindDependencyMacro)
32

3+
# Previously, this checked if "${_var}" (the variable name) existed as a file.
4+
# Now it correctly checks "${_file}" (the actual path).
5+
macro(set_and_check _var _file)
6+
set(${_var} "${_file}")
7+
if(NOT EXISTS "${_file}")
8+
message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist!")
9+
endif()
10+
endmacro()
11+
12+
# ---------------------------------------------------------------------------
413
# ZeroMQ library package
5-
# https://github.com/zeromq
14+
# ---------------------------------------------------------------------------
615
if(DMQ_TRANSPORT STREQUAL "DMQ_TRANSPORT_ZEROMQ")
7-
# vcpkg package manager
8-
# https://github.com/microsoft/vcpkg
9-
set_and_check(VCPKG_ROOT_DIR "${DMQ_ROOT_DIR}/../../../vcpkg")
16+
set(ZMQ_ROOT "${DMQ_ROOT_DIR}/../../../zeromq/install")
17+
list(APPEND CMAKE_PREFIX_PATH "${ZMQ_ROOT}")
1018

11-
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
12-
set_and_check(ZeroMQ_DIR "${VCPKG_ROOT_DIR}/installed/x64-windows/share/zeromq")
13-
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
14-
set_and_check(ZeroMQ_DIR "${VCPKG_ROOT_DIR}/installed/x64-linux-dynamic/share/zeromq")
15-
endif()
1619
find_package(ZeroMQ CONFIG REQUIRED)
20+
1721
if (ZeroMQ_FOUND)
1822
message(STATUS "ZeroMQ found: ${ZeroMQ_VERSION}")
23+
if(TARGET libzmq-static AND NOT TARGET libzmq)
24+
add_library(libzmq ALIAS libzmq-static)
25+
endif()
26+
add_compile_definitions(ZMQ_STATIC)
1927
else()
20-
message(FATAL_ERROR "ZeroMQ not found!")
28+
message(FATAL_ERROR "ZeroMQ not found in ${ZMQ_ROOT}")
2129
endif()
2230
endif()
2331

32+
# ---------------------------------------------------------------------------
2433
# NNG library
25-
# https://github.com/nanomsg/nng
34+
# ---------------------------------------------------------------------------
2635
if(DMQ_TRANSPORT STREQUAL "DMQ_TRANSPORT_NNG")
2736
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
28-
set_and_check(NNG_INCLUDE_DIR "${DMQ_ROOT_DIR}/../../../nng/include")
37+
# Fixed: Point to the 'install' folder where headers actually live after build
38+
set_and_check(NNG_INCLUDE_DIR "${DMQ_ROOT_DIR}/../../../nng/install/include")
2939
set_and_check(NNG_LIBRARY_DIR "${DMQ_ROOT_DIR}/../../../nng/install/lib")
3040
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
3141
set_and_check(NNG_INCLUDE_DIR "/usr/local/include/nng")
3242
set_and_check(NNG_LIBRARY_DIR "/usr/local/include/nng")
3343
endif()
3444
endif()
3545

46+
# ---------------------------------------------------------------------------
3647
# MQTT C library
37-
# https://github.com/eclipse-paho/paho.mqtt.c
48+
# ---------------------------------------------------------------------------
3849
if(DMQ_TRANSPORT STREQUAL "DMQ_TRANSPORT_MQTT")
50+
# Define root relative to DelegateMQ source
51+
set(MQTT_ROOT "${DMQ_ROOT_DIR}/../../../mqtt")
52+
3953
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
40-
set_and_check(MQTT_INCLUDE_DIR "${DMQ_ROOT_DIR}/../../../mqtt/paho-c/include")
41-
set_and_check(MQTT_LIBRARY_DIR "${DMQ_ROOT_DIR}/../../../mqtt/paho-c/lib")
42-
set_and_check(MQTT_BINARY_DIR "${DMQ_ROOT_DIR}/../../../mqtt/paho-c/bin")
54+
# 1. Headers
55+
# Note: If 'install' step wasn't run, headers might be in "${MQTT_ROOT}/src"
56+
set_and_check(MQTT_INCLUDE_DIR "${MQTT_ROOT}/install/include")
57+
58+
# 2. Library (Lib) Directory (for linking)
59+
# Point to build/src where the .lib files are generated
60+
set(MQTT_LIBRARY_DIR "${MQTT_ROOT}/build/src")
61+
62+
# 3. Binary (DLL) Directory (for runtime copy)
63+
# Point to build/src where the .dll files are generated
64+
set(MQTT_BINARY_DIR "${MQTT_ROOT}/build/src")
65+
66+
# Fallback for manual definition if needed
67+
set(MQTT_LIBRARY
68+
"${MQTT_LIBRARY_DIR}/paho-mqtt3c.lib"
69+
"ws2_32" "Rpcrt4" "Crypt32"
70+
)
4371
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
4472
set_and_check(MQTT_INCLUDE_DIR "/usr/local/include")
45-
set_and_check(MQTT_LIBRARY_DIR "/usr/local/lib")
46-
set_and_check(MQTT_BINARY_DIR "/usr/local/bin/MQTTVersion")
73+
set_and_check(MQTT_LIBRARY "/usr/local/lib/libpaho-mqtt3c.so")
74+
set_and_check(MQTT_BINARY_DIR "/usr/local/bin")
4775
endif()
4876
endif()
4977

50-
# MessagePack C++ library (msgpack.hpp)
51-
# https://github.com/msgpack/msgpack-c/tree/cpp_master
78+
# ---------------------------------------------------------------------------
79+
# MessagePack
80+
# ---------------------------------------------------------------------------
5281
if(DMQ_SERIALIZE STREQUAL "DMQ_SERIALIZE_MSGPACK")
82+
add_compile_definitions(MSGPACK_NO_BOOST)
5383
set_and_check(MSGPACK_INCLUDE_DIR "${DMQ_ROOT_DIR}/../../../msgpack-c/include")
5484
endif()
5585

56-
# Cereal C++ library
57-
# https://github.com/USCiLab/cereal
86+
# ---------------------------------------------------------------------------
87+
# Cereal
88+
# ---------------------------------------------------------------------------
5889
if(DMQ_SERIALIZE STREQUAL "DMQ_SERIALIZE_CEREAL")
5990
set_and_check(CEREAL_INCLUDE_DIR "${DMQ_ROOT_DIR}/../../../cereal/include")
6091
endif()
6192

62-
# Bitsery C++ library
63-
# https://github.com/fraillt/bitsery
93+
# ---------------------------------------------------------------------------
94+
# Bitsery
95+
# ---------------------------------------------------------------------------
6496
if(DMQ_SERIALIZE STREQUAL "DMQ_SERIALIZE_BITSERY")
6597
set_and_check(BITSERY_INCLUDE_DIR "${DMQ_ROOT_DIR}/../../../bitsery/include")
6698
endif()
6799

68-
# RapidJSON C++ library
69-
# https://github.com/Tencent/rapidjson
100+
# ---------------------------------------------------------------------------
101+
# RapidJSON
102+
# ---------------------------------------------------------------------------
70103
if(DMQ_SERIALIZE STREQUAL "DMQ_SERIALIZE_RAPIDJSON")
71104
set_and_check(RAPIDJSON_INCLUDE_DIR "${DMQ_ROOT_DIR}/../../../rapidjson/include")
105+
106+
# Globally silence C++17 std::iterator warnings on RapidJSON library
107+
if(MSVC)
108+
add_compile_definitions(_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING)
109+
endif()
72110
endif()
73111

74-
# FreeRTOS library
75-
# https://github.com/FreeRTOS/FreeRTOS
112+
# ---------------------------------------------------------------------------
113+
# FreeRTOS
114+
# ---------------------------------------------------------------------------
76115
if(DMQ_THREAD STREQUAL "DMQ_THREAD_FREERTOS")
77116
set_and_check(FREERTOS_ROOT_DIR "${DMQ_ROOT_DIR}/../../../FreeRTOSv202212.00")
78-
# Collect FreeRTOS source files
117+
79118
file(GLOB FREERTOS_SOURCES
80119
"${FREERTOS_ROOT_DIR}/FreeRTOS/Source/*.c"
81-
"${FREERTOS_ROOT_DIR}/FreeRTOS/Source/Include/*.h"
120+
"${FREERTOS_ROOT_DIR}/FreeRTOS/Source/include/*.h"
82121
)
83122
list(APPEND FREERTOS_SOURCES
84123
"${FREERTOS_ROOT_DIR}/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/trcKernelPort.c"
@@ -88,11 +127,9 @@ if(DMQ_THREAD STREQUAL "DMQ_THREAD_FREERTOS")
88127
)
89128
endif()
90129

91-
# spdlog
92-
# https://github.com/gabime/spdlog
130+
# ---------------------------------------------------------------------------
131+
# spdlog
132+
# ---------------------------------------------------------------------------
93133
if (DMQ_LOG STREQUAL "ON")
94134
set_and_check(SPDLOG_INCLUDE_DIR "${DMQ_ROOT_DIR}/../../../spdlog/include")
95-
endif()
96-
97-
98-
135+
endif()

0 commit comments

Comments
 (0)