-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
177 lines (144 loc) · 5.85 KB
/
CMakeLists.txt
File metadata and controls
177 lines (144 loc) · 5.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
cmake_minimum_required(VERSION 3.30)
project(MetricMQ CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
message(FATAL_ERROR "CMAKE_TOOLCHAIN_FILE not defined. Run cmake with -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake")
endif()
include(${CMAKE_BINARY_DIR}/conan_toolchain.cmake)
# Force C++17 minimum after toolchain inclusion
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Override Conan toolchain C++ standard
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Poco REQUIRED COMPONENTS Net Util JSON)
find_package(Boost REQUIRED)
find_package(lmdb REQUIRED)
find_package(spdlog REQUIRED)
find_package(benchmark REQUIRED)
find_package(libsodium REQUIRED)
# Core library
add_library(metricmq_lib STATIC
src/broker.cpp
src/session.cpp
src/resp_parser.cpp
src/binary_protocol.cpp
src/pubsub.cpp
src/binary_pubsub.cpp
src/queue.cpp
src/storage/LmdbStorage.cpp
src/logger.cpp
src/metrics.cpp
src/metrics_server.cpp
src/crypto/signing.cpp
src/crypto/keystore.cpp
)
target_include_directories(metricmq_lib PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
# lmdb, spdlog, and fmt include dirs propagate automatically from
# the Conan-generated targets in target_link_libraries below.
# Do NOT add machine-specific Conan cache paths here.
)
target_link_libraries(metricmq_lib PUBLIC
Poco::Net Poco::Util Poco::JSON
boost::boost # Includes asio, beast, system, etc.
lmdb::lmdb
spdlog::spdlog
libsodium::libsodium
)
# Platform-specific libraries
if(WIN32)
target_link_libraries(metricmq_lib PUBLIC ws2_32)
endif()
# Broker executable
add_executable(metricmq-broker src/main.cpp)
target_link_libraries(metricmq-broker PRIVATE metricmq_lib)
# Examples (link to library)
add_executable(simple_pub_sub examples/pubsub_raw_tcp.cpp)
target_link_libraries(simple_pub_sub PRIVATE metricmq_lib)
add_executable(pub_only examples/pub_only.cpp)
target_link_libraries(pub_only PRIVATE metricmq_lib)
add_executable(sub_only examples/sub_only.cpp)
target_link_libraries(sub_only PRIVATE metricmq_lib)
add_executable(pubsub_redis examples/pubsub_redis.cpp)
target_link_libraries(pubsub_redis PRIVATE metricmq_lib)
add_executable(throughput benchmark/throughput.cpp)
target_link_libraries(throughput PRIVATE metricmq_lib)
add_executable(protocol_benchmark benchmark/protocol_benchmark.cpp)
target_link_libraries(protocol_benchmark PRIVATE metricmq_lib)
# Binary protocol examples
add_executable(binary_pub_only examples/binary_pub_only.cpp)
target_link_libraries(binary_pub_only PRIVATE metricmq_lib)
add_executable(binary_sub_only examples/binary_sub_only.cpp)
target_link_libraries(binary_sub_only PRIVATE metricmq_lib)
# Queue mode examples
add_executable(push_only examples/push_only.cpp)
target_link_libraries(push_only PRIVATE metricmq_lib)
add_executable(pull_only examples/pull_only.cpp)
target_link_libraries(pull_only PRIVATE metricmq_lib)
add_executable(persistence_test examples/persistence_test.cpp)
target_link_libraries(persistence_test PRIVATE metricmq_lib)
add_executable(exactly_once_test examples/exactly_once_test.cpp)
target_link_libraries(exactly_once_test PRIVATE metricmq_lib)
# Crypto example
add_executable(crypto_demo examples/crypto_demo.cpp)
target_link_libraries(crypto_demo PRIVATE metricmq_lib)
add_executable(signed_publish_test examples/signed_publish_test.cpp)
target_link_libraries(signed_publish_test PRIVATE metricmq_lib)
# Tools
add_executable(metricmq-keygen tools/keygen.cpp)
target_link_libraries(metricmq-keygen PRIVATE metricmq_lib)
# Google Benchmark suite
add_executable(latency_benchmark benchmark/latency_benchmark.cpp)
target_link_libraries(latency_benchmark PRIVATE metricmq_lib benchmark::benchmark_main)
add_executable(throughput_benchmark benchmark/throughput_benchmark.cpp)
target_link_libraries(throughput_benchmark PRIVATE metricmq_lib benchmark::benchmark_main)
add_executable(protocol_comparison_benchmark benchmark/protocol_benchmark.cpp)
target_link_libraries(protocol_comparison_benchmark PRIVATE metricmq_lib benchmark::benchmark_main)
add_executable(persistence_benchmark benchmark/persistence_benchmark.cpp)
target_link_libraries(persistence_benchmark PRIVATE metricmq_lib benchmark::benchmark_main)
# ─── CTest integration ────────────────────────────────────────────────────────
# Run with:
# ctest --build-and-test ... --test-dir build/Release
# ctest -LE requires_broker # standalone tests only (CI-safe)
# ctest -L requires_broker # integration tests (need broker running)
enable_testing()
# Standalone — no broker needed; uses assert(), exits non-zero on failure
add_test(NAME signing_unit_test
COMMAND signed_publish_test
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
set_tests_properties(signing_unit_test PROPERTIES
LABELS "unit"
TIMEOUT 30
PASS_REGULAR_EXPRESSION "All.*tests passed|9/9"
)
# Standalone — exercises crypto API end-to-end, exits 0 on success
add_test(NAME crypto_demo_test
COMMAND crypto_demo
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
set_tests_properties(crypto_demo_test PROPERTIES
LABELS "unit"
TIMEOUT 15
PASS_REGULAR_EXPRESSION "Demo Complete"
)
# Integration — require a broker on 127.0.0.1:6379 before running
add_test(NAME exactly_once_integration
COMMAND exactly_once_test
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
set_tests_properties(exactly_once_integration PROPERTIES
LABELS "integration;requires_broker"
TIMEOUT 60
)
add_test(NAME persistence_integration
COMMAND persistence_test
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
set_tests_properties(persistence_integration PROPERTIES
LABELS "integration;requires_broker"
TIMEOUT 30
)