-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
132 lines (112 loc) · 4.32 KB
/
CMakeLists.txt
File metadata and controls
132 lines (112 loc) · 4.32 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
cmake_minimum_required(VERSION 3.20)
project(engine-sim-cli VERSION 1.0.0 LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Find required packages
find_package(Threads REQUIRED)
include(FetchContent)
FetchContent_Declare(
cli11
GIT_REPOSITORY https://github.com/CLIUtils/CLI11.git
GIT_TAG v2.5.0
)
FetchContent_MakeAvailable(cli11)
# Add engine-sim-bridge submodule
add_subdirectory(engine-sim-bridge ${CMAKE_BINARY_DIR}/engine-sim-bridge )
# -------------------------------------------------------------------
# iOS builds: only build the bridge static library, skip CLI and tests
# -------------------------------------------------------------------
if(IOS)
return()
endif()
# -------------------------------------------------------------------
# macOS CLI executable (not built for iOS)
# -------------------------------------------------------------------
# Platform-specific audio libraries
if(APPLE)
set(AUDIO_LIBRARY "-framework AudioToolbox -framework CoreAudio -framework CoreFoundation")
else()
message(FATAL_ERROR "engine-sim-cli only supports macOS with AudioQueue. Linux/Windows support has been removed.")
endif()
# CLI executable - thin CLI layer only
# Phase F: SimulationLoop, EngineConfig, IInputProvider, IPresentation moved to engine-sim-bridge
add_executable(engine-sim-cli
# Config layer
src/config/CLIconfig.cpp
src/config/CLIMain.cpp
src/config/ANSIColors.cpp
# Presentation layer
src/presentation/ConsolePresentation.cpp
# Input layer
src/input/KeyboardInput.cpp
src/input/KeyboardInputProvider.cpp
)
target_link_libraries(engine-sim-cli
PRIVATE
engine-sim-bridge
${AUDIO_LIBRARY}
Threads::Threads
CLI11::CLI11
)
target_include_directories(engine-sim-cli
PRIVATE
engine-sim-bridge/include
src
)
target_compile_options(engine-sim-cli PRIVATE -g)
# Set rpath for CLI executable to find dylibs in build directory
if(APPLE)
set_target_properties(engine-sim-cli PROPERTIES
BUILD_WITH_INSTALL_RPATH TRUE
INSTALL_RPATH "@executable_path"
BUILD_RPATH "@executable_path"
)
endif()
# Post-build: Copy engine-sim libraries from bridge build directory
add_custom_command(TARGET engine-sim-cli POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_BINARY_DIR}/engine-sim-bridge/libenginesim.dylib
${CMAKE_BINARY_DIR}/libenginesim.dylib
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_BINARY_DIR}/engine-sim-bridge/libenginesim.1.dylib
${CMAKE_BINARY_DIR}/libenginesim.1.dylib
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/engine-sim-bridge/engine-sim
${CMAKE_BINARY_DIR}/engine-sim-bridge/engine-sim
COMMENT "Copying engine-sim libraries from bridge build directory"
)
add_dependencies(engine-sim-cli engine-sim-bridge)
# Installation
install(TARGETS engine-sim-cli
RUNTIME DESTINATION bin
)
# -----------------------------------------------------------------------------
# Tests
# -----------------------------------------------------------------------------
option(BUILD_TESTS "Build engine-sim-cli unit tests" ON)
if(BUILD_TESTS)
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.12.1
)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
enable_testing()
add_subdirectory(test)
add_custom_target(run_tests
DEPENDS engine-sim-cli smoke_tests bridge_unit_tests
COMMAND ${CMAKE_COMMAND} -E echo "=== Bridge Unit Tests ==========================================="
COMMAND ${CMAKE_BINARY_DIR}/engine-sim-bridge/bridge_unit_tests --gtest_color=yes
COMMAND ${CMAKE_COMMAND} -E echo ""
COMMAND ${CMAKE_COMMAND} -E echo "=== CLI Smoke Tests ============================================="
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test/smoke_tests --gtest_color=yes
COMMAND ${CMAKE_COMMAND} -E echo ""
COMMAND ${CMAKE_COMMAND} -E echo "=== All tests complete ==========================================="
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Running all tests with real-time output"
)
endif()