|
| 1 | +cmake_minimum_required(VERSION 3.22) |
| 2 | +project(EdgeOrchestrator |
| 3 | + VERSION 1.0.0 |
| 4 | + DESCRIPTION "Distributed adaptive resource orchestrator for edge AI workloads" |
| 5 | + LANGUAGES CXX |
| 6 | +) |
| 7 | + |
| 8 | +# ────────────────────────────────────────────── |
| 9 | +# Global Settings |
| 10 | +# ────────────────────────────────────────────── |
| 11 | +set(CMAKE_CXX_STANDARD 20) |
| 12 | +set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 13 | +set(CMAKE_CXX_EXTENSIONS OFF) |
| 14 | +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) |
| 15 | + |
| 16 | +# ────────────────────────────────────────────── |
| 17 | +# Options |
| 18 | +# ────────────────────────────────────────────── |
| 19 | +option(BUILD_TESTS "Build unit and integration tests" ON) |
| 20 | +option(BUILD_TOOLS "Install Python analysis tools" OFF) |
| 21 | +option(ENABLE_SANITIZERS "Enable AddressSanitizer + UBSan" OFF) |
| 22 | +option(CROSS_COMPILE_ARM "Cross-compile for ARM64 (Raspberry Pi)" OFF) |
| 23 | + |
| 24 | +# ────────────────────────────────────────────── |
| 25 | +# Compiler Warnings |
| 26 | +# ────────────────────────────────────────────── |
| 27 | +add_compile_options( |
| 28 | + -Wall -Wextra -Wpedantic -Wshadow -Wnon-virtual-dtor |
| 29 | + -Wold-style-cast -Wcast-align -Wunused -Woverloaded-virtual |
| 30 | + -Wconversion -Wsign-conversion -Wnull-dereference |
| 31 | + -Wformat=2 -Wimplicit-fallthrough |
| 32 | +) |
| 33 | + |
| 34 | +if(ENABLE_SANITIZERS) |
| 35 | + add_compile_options(-fsanitize=address,undefined -fno-omit-frame-pointer) |
| 36 | + add_link_options(-fsanitize=address,undefined) |
| 37 | +endif() |
| 38 | + |
| 39 | +# ────────────────────────────────────────────── |
| 40 | +# Dependencies |
| 41 | +# ────────────────────────────────────────────── |
| 42 | +include(FetchContent) |
| 43 | + |
| 44 | +# Protobuf |
| 45 | +find_package(Protobuf REQUIRED) |
| 46 | + |
| 47 | +# nlohmann/json (header-only, for telemetry) |
| 48 | +FetchContent_Declare( |
| 49 | + json |
| 50 | + GIT_REPOSITORY https://github.com/nlohmann/json.git |
| 51 | + GIT_TAG v3.11.3 |
| 52 | +) |
| 53 | +FetchContent_MakeAvailable(json) |
| 54 | + |
| 55 | +# toml++ (header-only, for config) |
| 56 | +FetchContent_Declare( |
| 57 | + tomlplusplus |
| 58 | + GIT_REPOSITORY https://github.com/marzer/tomlplusplus.git |
| 59 | + GIT_TAG v3.4.0 |
| 60 | +) |
| 61 | +FetchContent_MakeAvailable(tomlplusplus) |
| 62 | + |
| 63 | +if(BUILD_TESTS) |
| 64 | + FetchContent_Declare( |
| 65 | + googletest |
| 66 | + GIT_REPOSITORY https://github.com/google/googletest.git |
| 67 | + GIT_TAG v1.14.0 |
| 68 | + ) |
| 69 | + set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) |
| 70 | + FetchContent_MakeAvailable(googletest) |
| 71 | + enable_testing() |
| 72 | +endif() |
| 73 | + |
| 74 | +# ────────────────────────────────────────────── |
| 75 | +# Protobuf Code Generation |
| 76 | +# ────────────────────────────────────────────── |
| 77 | +set(PROTO_FILES proto/protocol.proto) |
| 78 | +protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${PROTO_FILES}) |
| 79 | + |
| 80 | +# Generated headers go into build dir |
| 81 | +include_directories(${CMAKE_CURRENT_BINARY_DIR}) |
| 82 | + |
| 83 | +# ────────────────────────────────────────────── |
| 84 | +# Library Targets |
| 85 | +# ────────────────────────────────────────────── |
| 86 | + |
| 87 | +# Core |
| 88 | +add_library(eo_core STATIC |
| 89 | + src/core/logger.cpp |
| 90 | + src/core/config.cpp |
| 91 | +) |
| 92 | +target_include_directories(eo_core PUBLIC src) |
| 93 | +target_link_libraries(eo_core PUBLIC nlohmann_json::nlohmann_json tomlplusplus::tomlplusplus) |
| 94 | + |
| 95 | +# Resource Monitor |
| 96 | +add_library(eo_resource_monitor STATIC |
| 97 | + src/resource_monitor/linux_monitor.cpp |
| 98 | + src/resource_monitor/mock_monitor.cpp |
| 99 | +) |
| 100 | +target_include_directories(eo_resource_monitor PUBLIC src) |
| 101 | +target_link_libraries(eo_resource_monitor PUBLIC eo_core) |
| 102 | + |
| 103 | +# Workload |
| 104 | +add_library(eo_workload STATIC |
| 105 | + src/workload/dag.cpp |
| 106 | + src/workload/generator.cpp |
| 107 | +) |
| 108 | +target_include_directories(eo_workload PUBLIC src) |
| 109 | +target_link_libraries(eo_workload PUBLIC eo_core) |
| 110 | + |
| 111 | +# Scheduler |
| 112 | +add_library(eo_scheduler STATIC |
| 113 | + src/scheduler/greedy_policy.cpp |
| 114 | + src/scheduler/threshold_policy.cpp |
| 115 | + src/scheduler/optimizer_policy.cpp |
| 116 | + src/scheduler/cluster_view.cpp |
| 117 | +) |
| 118 | +target_include_directories(eo_scheduler PUBLIC src) |
| 119 | +target_link_libraries(eo_scheduler PUBLIC eo_core eo_workload) |
| 120 | + |
| 121 | +# Executor |
| 122 | +add_library(eo_executor STATIC |
| 123 | + src/executor/thread_pool.cpp |
| 124 | + src/executor/task_runner.cpp |
| 125 | + src/executor/memory_pool.cpp |
| 126 | +) |
| 127 | +target_include_directories(eo_executor PUBLIC src) |
| 128 | +target_link_libraries(eo_executor PUBLIC eo_core) |
| 129 | + |
| 130 | +# Network |
| 131 | +add_library(eo_network STATIC |
| 132 | + src/network/peer_discovery.cpp |
| 133 | + src/network/transport.cpp |
| 134 | + src/network/cluster_view.cpp |
| 135 | + ${PROTO_SRCS} |
| 136 | +) |
| 137 | +target_include_directories(eo_network PUBLIC src ${CMAKE_CURRENT_BINARY_DIR}) |
| 138 | +target_link_libraries(eo_network PUBLIC eo_core protobuf::libprotobuf) |
| 139 | + |
| 140 | +# Telemetry |
| 141 | +add_library(eo_telemetry STATIC |
| 142 | + src/telemetry/metrics_collector.cpp |
| 143 | + src/telemetry/json_sink.cpp |
| 144 | +) |
| 145 | +target_include_directories(eo_telemetry PUBLIC src) |
| 146 | +target_link_libraries(eo_telemetry PUBLIC eo_core nlohmann_json::nlohmann_json) |
| 147 | + |
| 148 | +# Orchestrator (facade — depends on all other modules) |
| 149 | +add_library(eo_orchestrator STATIC |
| 150 | + src/orchestrator/offload_codec.cpp |
| 151 | +) |
| 152 | +target_include_directories(eo_orchestrator PUBLIC src) |
| 153 | +target_link_libraries(eo_orchestrator PUBLIC |
| 154 | + eo_core eo_resource_monitor eo_workload eo_scheduler |
| 155 | + eo_executor eo_network eo_telemetry |
| 156 | +) |
| 157 | + |
| 158 | +# ────────────────────────────────────────────── |
| 159 | +# Main Daemon Executable |
| 160 | +# ────────────────────────────────────────────── |
| 161 | +add_executable(edge_orchestrator src/app/main.cpp) |
| 162 | +target_link_libraries(edge_orchestrator PRIVATE |
| 163 | + eo_orchestrator |
| 164 | + eo_core |
| 165 | + eo_resource_monitor |
| 166 | + eo_workload |
| 167 | + eo_scheduler |
| 168 | + eo_executor |
| 169 | + eo_network |
| 170 | + eo_telemetry |
| 171 | + pthread |
| 172 | +) |
| 173 | + |
| 174 | +# ────────────────────────────────────────────── |
| 175 | +# Tests |
| 176 | +# ────────────────────────────────────────────── |
| 177 | +if(BUILD_TESTS) |
| 178 | + add_subdirectory(tests) |
| 179 | +endif() |
| 180 | + |
| 181 | +# ────────────────────────────────────────────── |
| 182 | +# Install |
| 183 | +# ────────────────────────────────────────────── |
| 184 | +install(TARGETS edge_orchestrator DESTINATION bin) |
| 185 | +install(FILES config/default.toml DESTINATION etc/edge_orchestrator) |
0 commit comments