-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
561 lines (483 loc) · 23 KB
/
CMakeLists.txt
File metadata and controls
561 lines (483 loc) · 23 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
cmake_minimum_required(VERSION 3.16)
project(messaging_system
VERSION 0.1.0.0
DESCRIPTION "Modern messaging infrastructure with advanced patterns"
LANGUAGES CXX
)
# =============================================================================
# C++ Standard Configuration
# =============================================================================
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Explicit C++20 flags for all compilers
if(MSVC)
add_compile_options(/std:c++20)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
add_compile_options(-std=c++20)
endif()
# =============================================================================
# Build Options
# =============================================================================
# Feature flags
option(MESSAGING_USE_LOCKFREE "Enable lock-free data structures" OFF)
option(MESSAGING_ENABLE_MONITORING "Enable runtime monitoring" ON)
option(MESSAGING_ENABLE_LOGGING "Enable logging system" ON)
option(MESSAGING_ENABLE_METRICS "Enable metrics collection" ON)
option(MESSAGING_ENABLE_TLS "Enable TLS/SSL support" OFF)
option(MESSAGING_ENABLE_TRACING "Enable distributed tracing" ON)
option(MESSAGING_ENABLE_HEALTH_CHECKS "Enable health monitoring and circuit breakers" ON)
# Network system integration (for websocket_transport and http_transport)
option(KCENON_WITH_NETWORK_SYSTEM "Enable network_system integration for transport implementations" ON)
# Performance optimization flags
option(MESSAGING_ENABLE_MOVE_SEMANTICS "Enable zero-copy move semantics optimization" ON)
option(MESSAGING_ENABLE_SIMD "Enable SIMD optimizations for message processing" OFF)
option(MESSAGING_ENABLE_INLINE_OPTIMIZATION "Enable aggressive inlining for hot paths" ON)
# Dependency strategy (mapped to unified module options)
option(MESSAGING_USE_EXTERNAL_SYSTEMS "Use external system packages" ON)
option(MESSAGING_USE_FETCHCONTENT "Use FetchContent for dependencies" OFF)
option(MESSAGING_USE_LOCAL_SYSTEMS "Use local sibling directories for development" OFF)
# Development options
option(MESSAGING_BUILD_TESTS "Build unit tests" ON)
option(MESSAGING_BUILD_INTEGRATION_TESTS "Build integration tests" ON)
option(MESSAGING_BUILD_BENCHMARKS "Build performance benchmarks" OFF)
option(MESSAGING_BUILD_EXAMPLES "Build example applications" ON)
option(MESSAGING_BUILD_DOCS "Build documentation with Doxygen" OFF)
# =============================================================================
# C++20 Module Support (Experimental)
#
# Enable C++20 modules with CMake 3.28+ when building with module-capable compilers.
# This creates a separate module library target (messaging_system_modules) that can be
# used instead of the header-based library.
#
# Usage:
# cmake -DMESSAGING_BUILD_MODULES=ON ..
#
# Requirements:
# - CMake 3.28+
# - Clang 16+ or GCC 14+ or MSVC 17.4+
# =============================================================================
option(MESSAGING_BUILD_MODULES "Build C++20 module version of messaging_system" OFF)
# Build profile
set(MESSAGING_BUILD_PROFILE "Release" CACHE STRING "Build profile")
set_property(CACHE MESSAGING_BUILD_PROFILE PROPERTY STRINGS
"Debug" "Release" "RelWithDebInfo" "MinSizeRel"
"ASAN" "TSAN" "UBSAN" "MSAN" "Coverage"
)
# ABI Version
set(MESSAGING_ABI_VERSION 2 CACHE STRING "Messaging system ABI version")
# Performance tuning defaults
set(MESSAGING_DEFAULT_QUEUE_SIZE 10000 CACHE STRING "Default message queue size")
set(MESSAGING_DEFAULT_BATCH_SIZE 100 CACHE STRING "Default batch processing size")
set(MESSAGING_DEFAULT_WORKER_THREADS 4 CACHE STRING "Default number of worker threads")
# =============================================================================
# Compiler Settings
# =============================================================================
set(MESSAGING_WARNING_LEVEL "High" CACHE STRING "Compiler warning level")
if(MESSAGING_WARNING_LEVEL STREQUAL "High" OR MESSAGING_WARNING_LEVEL STREQUAL "Pedantic")
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
if(MESSAGING_WARNING_LEVEL STREQUAL "Pedantic")
add_compile_options(-Werror -Wconversion -Wsign-conversion)
endif()
elseif(MSVC)
add_compile_options(/W4)
# Disable C4996 (deprecated) warning due to common_system logger_interface.h
# internal deprecated method calls. See: https://github.com/kcenon/common_system/issues/XXX
add_compile_options(/wd4996)
if(MESSAGING_WARNING_LEVEL STREQUAL "Pedantic")
add_compile_options(/WX)
endif()
endif()
endif()
# Sanitizer flags
if(MESSAGING_BUILD_PROFILE STREQUAL "ASAN")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer -g")
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -fsanitize=address")
elseif(MESSAGING_BUILD_PROFILE STREQUAL "TSAN")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread -g")
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -fsanitize=thread")
elseif(MESSAGING_BUILD_PROFILE STREQUAL "UBSAN")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -fno-sanitize-recover=all -g")
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -fsanitize=undefined")
elseif(MESSAGING_BUILD_PROFILE STREQUAL "MSAN")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=memory -fno-omit-frame-pointer -g")
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -fsanitize=memory")
endif()
# =============================================================================
# External Dependencies (Unified Management)
# =============================================================================
if(MESSAGING_USE_EXTERNAL_SYSTEMS)
# Map messaging options to unified module options
set(UNIFIED_USE_LOCAL ${MESSAGING_USE_LOCAL_SYSTEMS} CACHE BOOL "" FORCE)
set(UNIFIED_USE_FETCHCONTENT ${MESSAGING_USE_FETCHCONTENT} CACHE BOOL "" FORCE)
# Include unified dependency management module
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(UnifiedDependencies)
# Setup dependency mode (LOCAL, FETCHCONTENT, or find_package)
unified_setup_dependency_mode()
# Required dependencies - ordered by dependency chain
# IMPORTANT: container_system MUST be last because it defines its own
# unified_find_dependency macro which overwrites ours. Any calls after
# container_system would use its macro (which lacks our configurations).
#
# NOTE: logger_system is no longer a direct dependency (Issue #94).
# Logging is now provided through common_system's ILogger interface
# with runtime binding via GlobalLoggerRegistry.
unified_find_dependency(common_system REQUIRED) # Tier 0: Base utilities + ILogger
unified_find_dependency(thread_system REQUIRED) # Tier 1: Threading
# Optional: network_system for transport implementations (websocket_transport, http_transport)
if(KCENON_WITH_NETWORK_SYSTEM)
unified_find_dependency(network_system REQUIRED) # Tier 2: Network I/O
else()
message(STATUS "Network system disabled - transport implementations will use stub mode")
endif()
# Optional dependencies (must come before container_system)
unified_find_dependency(monitoring_system OPTIONAL) # Metrics
unified_find_dependency(database_system OPTIONAL) # Persistence
# container_system MUST be loaded last (macro conflict workaround)
unified_find_dependency(container_system REQUIRED) # Tier 4: Serialization
# Fix: Ensure database_system gets container_system compile definitions.
# database_system is loaded before container_system (due to macro overwrite constraint),
# so it falls back to header-only linking without PUBLIC compile definitions.
# Re-link here with the proper CMake target to propagate definitions
# (e.g., KCENON_HAS_COMMON_SYSTEM=1 which gates Result-returning serialize APIs).
if(TARGET database AND TARGET container_system)
target_link_libraries(database PUBLIC container_system)
endif()
# Create standard aliases for consistent linking
unified_create_standard_aliases()
# Workaround for monitoring_system requiring kcenon::common_system alias
# See: https://github.com/kcenon/monitoring_system/issues/261
if(TARGET common_system AND NOT TARGET kcenon::common_system)
add_library(kcenon::common_system ALIAS common_system)
elseif(TARGET common AND NOT TARGET kcenon::common_system)
add_library(kcenon::common_system ALIAS common)
endif()
else()
message(STATUS "Building header-only library without external systems")
endif()
# Propagate options to external systems
if(MESSAGING_USE_LOCKFREE)
set(USE_LOCKFREE_BY_DEFAULT ON CACHE BOOL "" FORCE)
set(USE_LOCKFREE_THREAD_POOL ON CACHE BOOL "" FORCE)
endif()
if(MESSAGING_ENABLE_MONITORING)
set(ENABLE_MONITORING ON CACHE BOOL "" FORCE)
endif()
if(MESSAGING_ENABLE_LOGGING)
set(ENABLE_LOGGING ON CACHE BOOL "" FORCE)
endif()
if(MESSAGING_ENABLE_TLS)
set(ENABLE_TLS ON CACHE BOOL "" FORCE)
endif()
# =============================================================================
# Messaging System Core Library
# =============================================================================
set(MESSAGING_CORE_SOURCES
src/impl/core/message.cpp
src/impl/core/message_queue.cpp
src/impl/core/topic_router.cpp
src/impl/core/message_bus.cpp
src/impl/core/message_broker.cpp
src/impl/backends/standalone_backend.cpp
src/impl/backends/integration_backend.cpp
src/impl/di/messaging_di_container.cpp
src/impl/di/service_registry.cpp
src/impl/patterns/pub_sub.cpp
src/impl/patterns/request_reply.cpp
src/impl/patterns/event_streaming.cpp
src/impl/patterns/message_pipeline.cpp
# Task module (Distributed Task Queue System)
src/impl/task/task.cpp
src/impl/task/task_context.cpp
src/impl/task/task_queue.cpp
src/impl/task/memory_result_backend.cpp
src/impl/task/worker_pool.cpp
src/impl/task/async_result.cpp
src/impl/task/task_client.cpp
src/impl/task/cron_parser.cpp
src/impl/task/scheduler.cpp
src/impl/task/monitor.cpp
src/impl/task/task_system.cpp
# Collectors module (monitoring_system integration)
src/impl/collectors/message_bus_collector.cpp
# Adapters module (transport implementations)
src/impl/adapters/websocket_transport.cpp
src/impl/adapters/http_transport.cpp
)
add_library(messaging_system_core STATIC ${MESSAGING_CORE_SOURCES})
set_target_properties(messaging_system_core PROPERTIES
CXX_STANDARD 20
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
POSITION_INDEPENDENT_CODE ON
)
target_include_directories(messaging_system_core
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/impl
)
# Link dependencies using unified target variables
if(container_system_TARGET)
target_link_libraries(messaging_system_core PUBLIC ${container_system_TARGET})
elseif(TARGET container)
target_link_libraries(messaging_system_core PUBLIC container)
elseif(TARGET ContainerSystem::container)
target_link_libraries(messaging_system_core PUBLIC ContainerSystem::container)
endif()
if(common_system_TARGET)
target_link_libraries(messaging_system_core PUBLIC ${common_system_TARGET})
# Enable IExecutor interface in thread_pool when common_system is available
target_compile_definitions(messaging_system_core PUBLIC KCENON_HAS_COMMON_EXECUTOR=1)
elseif(TARGET common)
target_link_libraries(messaging_system_core PUBLIC common)
target_compile_definitions(messaging_system_core PUBLIC KCENON_HAS_COMMON_EXECUTOR=1)
elseif(TARGET CommonSystem::common)
target_link_libraries(messaging_system_core PUBLIC CommonSystem::common)
target_compile_definitions(messaging_system_core PUBLIC KCENON_HAS_COMMON_EXECUTOR=1)
endif()
# Link thread_system (required for task_queue's delayed_task_worker)
if(thread_system_TARGET)
target_link_libraries(messaging_system_core PUBLIC ${thread_system_TARGET})
elseif(TARGET thread_pool)
target_link_libraries(messaging_system_core PUBLIC thread_pool)
elseif(TARGET ThreadSystem::thread_pool)
target_link_libraries(messaging_system_core PUBLIC ThreadSystem::thread_pool)
endif()
# Compile definitions
target_compile_definitions(messaging_system_core PUBLIC
KCENON_MESSAGING_SYSTEM_AVAILABLE
MESSAGING_ABI_VERSION=${MESSAGING_ABI_VERSION}
MESSAGING_DEFAULT_QUEUE_SIZE=${MESSAGING_DEFAULT_QUEUE_SIZE}
MESSAGING_DEFAULT_BATCH_SIZE=${MESSAGING_DEFAULT_BATCH_SIZE}
MESSAGING_DEFAULT_WORKER_THREADS=${MESSAGING_DEFAULT_WORKER_THREADS}
)
# Network system integration compile definition
if(KCENON_WITH_NETWORK_SYSTEM)
target_compile_definitions(messaging_system_core PUBLIC KCENON_WITH_NETWORK_SYSTEM=1)
else()
target_compile_definitions(messaging_system_core PUBLIC KCENON_WITH_NETWORK_SYSTEM=0)
endif()
# Feature-specific compile definitions and options
if(MESSAGING_ENABLE_MOVE_SEMANTICS)
target_compile_definitions(messaging_system_core PUBLIC MESSAGING_ENABLE_MOVE_SEMANTICS)
endif()
if(MESSAGING_ENABLE_SIMD)
target_compile_definitions(messaging_system_core PUBLIC MESSAGING_ENABLE_SIMD)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64")
target_compile_options(messaging_system_core PRIVATE
$<$<CXX_COMPILER_ID:GNU,Clang>:-mavx2 -mfma>
$<$<CXX_COMPILER_ID:MSVC>:/arch:AVX2>
)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm|aarch64|ARM64")
target_compile_options(messaging_system_core PRIVATE
$<$<CXX_COMPILER_ID:GNU,Clang>:-march=armv8-a+simd>
)
endif()
endif()
if(MESSAGING_ENABLE_INLINE_OPTIMIZATION)
target_compile_definitions(messaging_system_core PUBLIC MESSAGING_ENABLE_INLINE_OPTIMIZATION)
target_compile_options(messaging_system_core PRIVATE
$<$<CXX_COMPILER_ID:GNU,Clang>:-finline-functions -finline-limit=600>
$<$<CXX_COMPILER_ID:MSVC>:/Ob2>
)
endif()
if(MESSAGING_ENABLE_TRACING)
target_compile_definitions(messaging_system_core PUBLIC MESSAGING_ENABLE_TRACING)
endif()
if(MESSAGING_ENABLE_HEALTH_CHECKS)
target_compile_definitions(messaging_system_core PUBLIC MESSAGING_ENABLE_HEALTH_CHECKS)
endif()
# Link monitoring_system if available (for message_bus_collector)
if(monitoring_system_TARGET)
target_link_libraries(messaging_system_core PUBLIC ${monitoring_system_TARGET})
target_compile_definitions(messaging_system_core PUBLIC WITH_MONITORING_SYSTEM)
elseif(TARGET monitoring)
target_link_libraries(messaging_system_core PUBLIC monitoring)
target_compile_definitions(messaging_system_core PUBLIC WITH_MONITORING_SYSTEM)
elseif(TARGET MonitoringSystem::monitoring)
target_link_libraries(messaging_system_core PUBLIC MonitoringSystem::monitoring)
target_compile_definitions(messaging_system_core PUBLIC WITH_MONITORING_SYSTEM)
endif()
# Workaround: monitoring_system's INTERFACE target propagates /WX and /w14996,
# which re-enables C4996 warnings (deprecated CRT functions like std::gmtime in
# thread_system's execution_event.h) and treats them as errors.
# CMake appends INTERFACE options AFTER target PRIVATE options, so MSVC's
# "last flag wins" rule means /w14996 overrides our /wd4996.
# Fix: strip the problematic flags from the INTERFACE target directly.
if(MSVC AND TARGET monitoring_system_interface)
get_target_property(_monitor_opts monitoring_system_interface INTERFACE_COMPILE_OPTIONS)
if(_monitor_opts)
list(REMOVE_ITEM _monitor_opts "/WX" "/w14996")
set_target_properties(monitoring_system_interface PROPERTIES
INTERFACE_COMPILE_OPTIONS "${_monitor_opts}")
endif()
endif()
# Link network_system if available (for websocket_transport, http_transport)
# Note: PRIVATE because PIMPL pattern hides network_system from public headers
if(KCENON_WITH_NETWORK_SYSTEM)
if(network_system_TARGET)
target_link_libraries(messaging_system_core PRIVATE ${network_system_TARGET})
elseif(TARGET network)
target_link_libraries(messaging_system_core PRIVATE network)
elseif(TARGET NetworkSystem::network)
target_link_libraries(messaging_system_core PRIVATE NetworkSystem::network)
endif()
# Workaround: network_system v2.0 moved transport implementation headers
# (messaging_ws_client.h, http_client.h) from include/ to src/internal/.
# Grant PRIVATE access to src/ until transport adapters migrate to the
# new facade API (Issue #217).
foreach(_ns_target NetworkSystem network network_system)
if(TARGET ${_ns_target})
get_target_property(_ns_src ${_ns_target} SOURCE_DIR)
if(_ns_src AND EXISTS "${_ns_src}/src")
target_include_directories(messaging_system_core PRIVATE "${_ns_src}/src")
message(STATUS "Added network_system internal headers: ${_ns_src}/src")
endif()
break()
endif()
endforeach()
# Workaround: network_system links asio as PRIVATE, so asio headers are not
# propagated to dependent targets. We need to find and link asio directly
# to ensure asio.hpp is available when compiling network_system headers.
# See: https://github.com/kcenon/network_system/issues/XXX
find_package(asio CONFIG QUIET)
if(TARGET asio::asio)
target_link_libraries(messaging_system_core PUBLIC asio::asio)
target_compile_definitions(messaging_system_core PUBLIC ASIO_STANDALONE ASIO_NO_DEPRECATED)
if(WIN32)
target_compile_definitions(messaging_system_core PUBLIC _WIN32_WINNT=0x0601)
endif()
message(STATUS "Linked asio::asio directly to messaging_system_core (network_system workaround)")
endif()
endif()
# =============================================================================
# Tests, Examples, Documentation
# =============================================================================
if(MESSAGING_BUILD_TESTS)
include(CTest)
enable_testing()
add_subdirectory(test)
if(MESSAGING_BUILD_INTEGRATION_TESTS AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/integration_tests/CMakeLists.txt)
add_subdirectory(integration_tests)
endif()
endif()
if(MESSAGING_BUILD_EXAMPLES AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/examples/CMakeLists.txt)
add_subdirectory(examples)
endif()
if(MESSAGING_BUILD_DOCS)
find_package(Doxygen)
if(DOXYGEN_FOUND AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/docs)
add_subdirectory(docs)
endif()
endif()
# =============================================================================
# C++20 Module Library Target
# =============================================================================
if(MESSAGING_BUILD_MODULES)
if(CMAKE_VERSION VERSION_LESS "3.28")
message(WARNING "C++20 modules require CMake 3.28+. Disabling module build.")
set(MESSAGING_BUILD_MODULES OFF)
else()
message(STATUS "C++20 module build enabled")
# Create module library target
add_library(messaging_system_modules)
add_library(kcenon::messaging_modules ALIAS messaging_system_modules)
# Set C++20 standard for module target
target_compile_features(messaging_system_modules PUBLIC cxx_std_20)
# Enable module scanning
set_target_properties(messaging_system_modules PROPERTIES
CXX_SCAN_FOR_MODULES ON
)
# Add module source files
target_sources(messaging_system_modules
PUBLIC FILE_SET CXX_MODULES
FILES
# Primary module
src/modules/messaging.cppm
# Partitions
src/modules/core.cppm
src/modules/patterns.cppm
src/modules/task.cppm
src/modules/integration.cppm
)
# Include directories for module target
target_include_directories(messaging_system_modules PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
# Link dependencies for module compilation.
# The global module fragment #includes upstream headers (e.g., core/container.h),
# so we need their include directories available during dependency scanning.
# Link to messaging_system_core (PRIVATE) to transitively get all upstream
# include paths, then optionally link upstream module targets (PUBLIC) when
# they become available.
target_link_libraries(messaging_system_modules PRIVATE messaging_system_core)
# When upstream systems provide C++20 module targets, link them publicly
# so consumers can import the full module dependency chain.
foreach(_mod_target
kcenon::common_modules
kcenon::thread_modules
kcenon::container_modules
kcenon::logger_modules
kcenon::database_modules
kcenon::network_modules
)
if(TARGET ${_mod_target})
target_link_libraries(messaging_system_modules PUBLIC ${_mod_target})
endif()
endforeach()
# Define compile-time flags
target_compile_definitions(messaging_system_modules PUBLIC
KCENON_MESSAGING_MODULES=1
KCENON_USE_MODULES=1
)
message(STATUS "C++20 module target: messaging_system_modules")
endif()
endif()
# =============================================================================
# Installation
# =============================================================================
if(NOT MESSAGING_USE_LOCAL_SYSTEMS
AND NOT MESSAGING_USE_FETCHCONTENT
AND CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
include(GNUInstallDirs)
install(TARGETS messaging_system_core
EXPORT messaging_system_targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(DIRECTORY include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(EXPORT messaging_system_targets
FILE messaging_system-targets.cmake
NAMESPACE MessagingSystem::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/messaging_system
)
endif()
# =============================================================================
# Configuration Summary
# =============================================================================
message(STATUS "")
message(STATUS "=== Messaging System Configuration ===")
message(STATUS "Version: ${PROJECT_VERSION} (ABI: ${MESSAGING_ABI_VERSION})")
message(STATUS "Build: ${CMAKE_BUILD_TYPE} / ${MESSAGING_BUILD_PROFILE}")
message(STATUS "")
message(STATUS "Features: Lock-free=${MESSAGING_USE_LOCKFREE}, TLS=${MESSAGING_ENABLE_TLS}")
message(STATUS " Tracing=${MESSAGING_ENABLE_TRACING}, Health=${MESSAGING_ENABLE_HEALTH_CHECKS}")
message(STATUS " NetworkSystem=${KCENON_WITH_NETWORK_SYSTEM}")
message(STATUS "")
message(STATUS "Build options: Tests=${MESSAGING_BUILD_TESTS}, Examples=${MESSAGING_BUILD_EXAMPLES}")
message(STATUS " C++20 Modules=${MESSAGING_BUILD_MODULES}")
message(STATUS "")
if(MESSAGING_USE_EXTERNAL_SYSTEMS)
unified_print_dependency_summary()
endif()
message(STATUS "=======================================")
message(STATUS "")