-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
231 lines (199 loc) · 8.62 KB
/
Copy pathCMakeLists.txt
File metadata and controls
231 lines (199 loc) · 8.62 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
# =============================================================================
# Axon by ArcheBase - Root CMake Configuration
# =============================================================================
# This file provides centralized configuration for all Axon modules.
# Individual modules can be built standalone (for faster iteration) or
# together from the repository root.
#
# Build from root:
# cmake -B build -S . -DAXON_BUILD_TESTS=ON
# cmake --build build
#
# Build individual modules (still works):
# cmake -B build -S core/axon_mcap
# =============================================================================
cmake_minimum_required(VERSION 3.14)
project(Axon VERSION 0.4.0 LANGUAGES CXX)
# =============================================================================
# Centralized Path Definitions
# =============================================================================
# All modules use these variables instead of computing relative paths.
# This ensures consistency across the codebase.
get_filename_component(AXON_REPO_ROOT "${CMAKE_CURRENT_SOURCE_DIR}" ABSOLUTE)
set(AXON_CORE_DIR "${AXON_REPO_ROOT}/core")
set(AXON_LOGGING_DIR "${AXON_CORE_DIR}/axon_logging")
set(AXON_MCAP_DIR "${AXON_CORE_DIR}/axon_mcap")
set(AXON_UPLOADER_DIR "${AXON_CORE_DIR}/axon_uploader")
set(AXON_MEMORY_DIR "${AXON_CORE_DIR}/axon_memory")
set(AXON_MIDDLEWARES_DIR "${AXON_REPO_ROOT}/middlewares")
set(AXON_APPS_DIR "${AXON_REPO_ROOT}/apps")
set(AXON_CMAKE_MODULES_DIR "${AXON_REPO_ROOT}/cmake/Modules")
# Make variables available to child CMakeLists
set(AXON_REPO_ROOT "${AXON_REPO_ROOT}" CACHE INTERNAL "")
set(AXON_CORE_DIR "${AXON_CORE_DIR}" CACHE INTERNAL "")
set(AXON_LOGGING_DIR "${AXON_LOGGING_DIR}" CACHE INTERNAL "")
set(AXON_MCAP_DIR "${AXON_MCAP_DIR}" CACHE INTERNAL "")
set(AXON_UPLOADER_DIR "${AXON_UPLOADER_DIR}" CACHE INTERNAL "")
set(AXON_MEMORY_DIR "${AXON_MEMORY_DIR}" CACHE INTERNAL "")
set(AXON_MIDDLEWARES_DIR "${AXON_MIDDLEWARES_DIR}" CACHE INTERNAL "")
set(AXON_APPS_DIR "${AXON_APPS_DIR}" CACHE INTERNAL "")
set(AXON_CMAKE_MODULES_DIR "${AXON_CMAKE_MODULES_DIR}" CACHE INTERNAL "")
# =============================================================================
# Common CMake Policies
# =============================================================================
# These policies apply to all Axon modules.
# Suppress CMP0167 warning (FindBoost module removed in CMake 3.30+)
# Use modern BoostConfig.cmake instead of FindBoost.cmake
if(POLICY CMP0167)
cmake_policy(SET CMP0167 NEW)
endif()
# =============================================================================
# Shared Options
# =============================================================================
# These options can be set from the command line and propagate to all modules.
option(AXON_ENABLE_COVERAGE "Enable code coverage for all Axon modules" OFF)
option(AXON_BUILD_TESTS "Build tests for all Axon modules" OFF)
option(AXON_BUILD_UPLOADER "Build axon_uploader (requires AWS SDK)" OFF)
# Enable testing globally
if(AXON_BUILD_TESTS)
enable_testing()
endif()
# =============================================================================
# Include CMake Modules
# =============================================================================
list(APPEND CMAKE_MODULE_PATH "${AXON_CMAKE_MODULES_DIR}")
# Include standard library utilities FIRST (required by all modules)
include(AxonStdLib REQUIRED)
include(AxonCoverage OPTIONAL)
# =============================================================================
# Shared Dependencies
# =============================================================================
# These dependencies are fetched once and reused by all modules.
# Set CMP0135 policy to NEW behavior for CMake 3.25+
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.25")
cmake_policy(SET CMP0135 NEW)
endif()
# Set CMP0136 policy to OLD to avoid tar --touch flag incompatibility
# CMake 3.24+ uses --touch flag which older tar versions don't support
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24")
cmake_policy(SET CMP0136 OLD)
endif()
include(FetchContent)
# Find Threads (required by Boost::thread)
find_package(Threads REQUIRED)
# nlohmann/json - shared across all modules
FetchContent_Declare(
nlohmann_json
URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz
URL_HASH
SHA256=d6c65aca6b1ed68e7a182f4757257b107ae403032760ed6ef121c9d55e81757d
)
FetchContent_MakeAvailable(nlohmann_json)
# =============================================================================
# Module Subdirectories
# =============================================================================
# Add C++ libraries in dependency order.
# =============================================================================
# Memory (no dependencies)
# =============================================================================
if(EXISTS "${AXON_MEMORY_DIR}/CMakeLists.txt")
add_subdirectory(${AXON_MEMORY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/axon_memory)
endif()
# =============================================================================
# Logging (no dependencies)
# =============================================================================
if(EXISTS "${AXON_LOGGING_DIR}/CMakeLists.txt")
add_subdirectory(
${AXON_LOGGING_DIR}
${CMAKE_CURRENT_BINARY_DIR}/axon_logging
)
endif()
# =============================================================================
# MCAP (depends on logging)
# =============================================================================
if(EXISTS "${AXON_MCAP_DIR}/CMakeLists.txt")
add_subdirectory(${AXON_MCAP_DIR} ${CMAKE_CURRENT_BINARY_DIR}/axon_mcap)
endif()
# =============================================================================
# Uploader (depends on MCAP, logging, AWS SDK)
# =============================================================================
if(AXON_BUILD_UPLOADER AND EXISTS "${AXON_UPLOADER_DIR}/CMakeLists.txt")
add_subdirectory(
${AXON_UPLOADER_DIR}
${CMAKE_CURRENT_BINARY_DIR}/axon_uploader
)
endif()
# =============================================================================
# Middlewares (ROS1, ROS2, Zenoh, Mock)
# =============================================================================
if(EXISTS "${AXON_MIDDLEWARES_DIR}/CMakeLists.txt")
add_subdirectory(
${AXON_MIDDLEWARES_DIR}
${CMAKE_CURRENT_BINARY_DIR}/middlewares
)
endif()
# =============================================================================
# Applications
# =============================================================================
if(EXISTS "${AXON_APPS_DIR}/axon_recorder/CMakeLists.txt")
add_subdirectory(
${AXON_APPS_DIR}/axon_recorder
${CMAKE_CURRENT_BINARY_DIR}/axon_recorder
)
endif()
if(EXISTS "${AXON_APPS_DIR}/axon_config/CMakeLists.txt")
add_subdirectory(
${AXON_APPS_DIR}/axon_config
${CMAKE_CURRENT_BINARY_DIR}/axon_config
)
endif()
if(EXISTS "${AXON_APPS_DIR}/axon_transfer/CMakeLists.txt")
add_subdirectory(
${AXON_APPS_DIR}/axon_transfer
${CMAKE_CURRENT_BINARY_DIR}/axon_transfer
)
endif()
if(EXISTS "${AXON_APPS_DIR}/axon_agent/CMakeLists.txt")
add_subdirectory(
${AXON_APPS_DIR}/axon_agent
${CMAKE_CURRENT_BINARY_DIR}/axon_agent
)
endif()
if(EXISTS "${AXON_APPS_DIR}/axon_system/CMakeLists.txt")
add_subdirectory(
${AXON_APPS_DIR}/axon_system
${CMAKE_CURRENT_BINARY_DIR}/axon_system
)
endif()
if(EXISTS "${AXON_APPS_DIR}/axon_panel/CMakeLists.txt")
add_subdirectory(
${AXON_APPS_DIR}/axon_panel
${CMAKE_CURRENT_BINARY_DIR}/axon_panel
)
endif()
if(EXISTS "${AXON_APPS_DIR}/axon_dispatcher/CMakeLists.txt")
add_subdirectory(
${AXON_APPS_DIR}/axon_dispatcher
${CMAKE_CURRENT_BINARY_DIR}/axon_dispatcher
)
endif()
if(EXISTS "${AXON_APPS_DIR}/plugin_example/CMakeLists.txt")
add_subdirectory(
${AXON_APPS_DIR}/plugin_example
${CMAKE_CURRENT_BINARY_DIR}/plugin_example
)
endif()
# =============================================================================
# Summary
# =============================================================================
message(STATUS "")
message(STATUS "=== Axon Configuration ===")
message(STATUS " Repository Root: ${AXON_REPO_ROOT}")
message(STATUS " Core Libraries: ${AXON_CORE_DIR}")
message(STATUS " Middlewares: ${AXON_MIDDLEWARES_DIR}")
message(STATUS " Applications: ${AXON_APPS_DIR}")
message(STATUS " Coverage: ${AXON_ENABLE_COVERAGE}")
message(STATUS " Tests: ${AXON_BUILD_TESTS}")
message(STATUS " Uploader: ${AXON_BUILD_UPLOADER}")
message(STATUS "=====================================")
message(STATUS "")