-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
124 lines (106 loc) · 3.83 KB
/
CMakeLists.txt
File metadata and controls
124 lines (106 loc) · 3.83 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
cmake_minimum_required(VERSION 3.15)
project(RS2VServer VERSION 1.0.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Build options
option(ENABLE_TELEMETRY "Enable telemetry system" ON)
option(ENABLE_SCRIPTING "Enable C# scripting support" ON)
option(ENABLE_COMPRESSION "Enable packet compression" ON)
option(BUILD_TESTS "Build test suite" OFF)
# Compiler flags
if(MSVC)
add_compile_options(/W4 /permissive-)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS WIN32_LEAN_AND_MEAN NOMINMAX)
else()
add_compile_options(-Wall -Wextra -Wpedantic)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_options(-g -O0)
else()
add_compile_options(-O2)
endif()
endif()
# Include paths — src/ holds both headers and sources
include_directories(${CMAKE_SOURCE_DIR}/src)
include_directories(${CMAKE_SOURCE_DIR}/include)
# Create Math/ -> Physics/ symlink so #include "Math/Vector3.h" resolves
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/src/Math")
file(CREATE_LINK
"${CMAKE_SOURCE_DIR}/src/Physics"
"${CMAKE_SOURCE_DIR}/src/Math"
SYMBOLIC)
endif()
# Find dependencies
find_package(OpenSSL QUIET)
find_package(Threads REQUIRED)
find_package(ZLIB QUIET)
# Collect all source files
file(GLOB_RECURSE CORE_SOURCES
src/Config/*.cpp
src/Game/*.cpp
src/Network/*.cpp
src/Physics/*.cpp
src/Protocol/*.cpp
src/Security/*.cpp
src/Time/*.cpp
src/Utils/*.cpp
)
# Exclude CodeGen.cpp (standalone code generation tool with its own main)
list(FILTER CORE_SOURCES EXCLUDE REGEX "CodeGen\\.cpp$")
# Scripting sources (optional)
if(ENABLE_SCRIPTING)
file(GLOB_RECURSE SCRIPTING_SOURCES src/Scripting/*.cpp)
list(APPEND CORE_SOURCES ${SCRIPTING_SOURCES})
add_compile_definitions(RS2V_SCRIPTING_ENABLED)
endif()
# Telemetry sources (optional)
if(ENABLE_TELEMETRY)
file(GLOB_RECURSE TELEMETRY_SOURCES telemetry/*.cpp)
list(APPEND CORE_SOURCES ${TELEMETRY_SOURCES})
include_directories(${CMAKE_SOURCE_DIR}/telemetry)
add_compile_definitions(RS2V_TELEMETRY_ENABLED)
endif()
# Main server executable
add_executable(rs2v_server
src/main.cpp
${CORE_SOURCES}
)
target_link_libraries(rs2v_server PRIVATE Threads::Threads)
# Platform-specific link libraries
if(WIN32)
target_link_libraries(rs2v_server PRIVATE ws2_32 iphlpapi)
else()
target_link_libraries(rs2v_server PRIVATE dl)
endif()
# OpenSSL (optional — ProtocolUtils uses it for Base64)
if(OpenSSL_FOUND)
target_link_libraries(rs2v_server PRIVATE OpenSSL::SSL OpenSSL::Crypto)
target_compile_definitions(rs2v_server PRIVATE RS2V_HAS_OPENSSL)
else()
message(STATUS "OpenSSL not found — Base64 will use built-in implementation")
endif()
# zlib (optional — CompressionHandler uses it)
if(ZLIB_FOUND)
target_link_libraries(rs2v_server PRIVATE ZLIB::ZLIB)
target_compile_definitions(rs2v_server PRIVATE RS2V_HAS_ZLIB)
else()
message(STATUS "zlib not found — compression will use built-in stub")
endif()
# Filesystem support (GCC < 9 needs explicit linkage)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
target_link_libraries(rs2v_server PRIVATE stdc++fs)
endif()
# Install target
install(TARGETS rs2v_server RUNTIME DESTINATION bin)
install(DIRECTORY config/ DESTINATION etc/rs2v)
install(DIRECTORY data/ DESTINATION share/rs2v/data)
message(STATUS "")
message(STATUS "RS2V Server v${PROJECT_VERSION}")
message(STATUS " Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS " Telemetry: ${ENABLE_TELEMETRY}")
message(STATUS " Scripting: ${ENABLE_SCRIPTING}")
message(STATUS " Compression: ${ENABLE_COMPRESSION}")
message(STATUS " OpenSSL: ${OpenSSL_FOUND}")
message(STATUS " zlib: ${ZLIB_FOUND}")
message(STATUS "")