-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
221 lines (188 loc) · 5.25 KB
/
CMakeLists.txt
File metadata and controls
221 lines (188 loc) · 5.25 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
cmake_minimum_required(VERSION 3.15)
project(GameServer)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(fmt REQUIRED)
if(NOT TARGET asio::asio)
message(STATUS "ASIO not found via find_package, using manual configuration")
set(ASIO_DIR "${CMAKE_SOURCE_DIR}/thirdparty/asio")
set(ASIO_INCLUDE_DIRS "${ASIO_DIR}/asio/include")
add_library(asio INTERFACE)
target_include_directories(asio INTERFACE ${ASIO_INCLUDE_DIRS})
target_compile_definitions(asio INTERFACE ASIO_STANDALONE)
add_library(asio::asio ALIAS asio)
else()
message(STATUS "ASIO found via find_package")
endif()
# Add GLM include directory
set(GLM_DIR "${CMAKE_SOURCE_DIR}/thirdparty/glm")
set(GLM_INCLUDE_DIRS "${GLM_DIR}")
include_directories(${glm_INCLUDE_DIRS})
find_package(nlohmann_json 3.2.0 QUIET)
if(NOT nlohmann_json_FOUND)
message(WARNING "nlohmann_json not found, using FetchContent...")
include(FetchContent)
FetchContent_Declare(
nlohmann_json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.11.2
)
FetchContent_MakeAvailable(nlohmann_json)
endif()
find_package(spdlog 1.13.0 QUIET)
if(NOT spdlog_FOUND)
# Fall back to cloned version
message(STATUS "System spdlog not found, using local clone")
set(SPDLOG_DIR "${CMAKE_SOURCE_DIR}/thirdparty/spdlog")
add_subdirectory(${SPDLOG_DIR} EXCLUDE_FROM_ALL)
endif()
# Options for database backends
option(USE_CITUS "Enable Citus distributed database support" OFF)
option(USE_SQLITE "Enable SQLite embedded database support" OFF)
# Find dependencies
find_package(OpenGL REQUIRED)
find_package(PostgreSQL REQUIRED)
find_package(Python3 REQUIRED COMPONENTS Development)
if(USE_SQLITE)
find_package(SQLite3 REQUIRED)
endif()
# Find zlib for compression
find_package(ZLIB REQUIRED)
# Find OpenSSL for encryption
find_package(OpenSSL REQUIRED)
# Find UUID library
find_library(UUID_LIBRARY NAMES uuid)
if(NOT UUID_LIBRARY)
message(FATAL_ERROR "libuuid not found - install libuuid-dev or equivalent")
endif()
find_library(CRYPT_LIB crypt)
# Config system
set(CONFIG_SOURCES
src/config/ConfigManager.cpp
)
# Logging system
set(LOGGING_SOURCES
src/logging/Logger.cpp
)
# Process system
set(PROCESS_SOURCES
src/process/ProcessPool.cpp
)
# Scripting system
set(SCRIPTING_SOURCES
src/scripting/PythonAPI.cpp
src/scripting/PythonModule.cpp
src/scripting/PythonScripting.cpp
src/scripting/ScriptHotReloader.cpp
)
# Network system
set(NETWORK_SOURCES
src/network/BinaryProtocol.cpp
src/network/ConnectionManager.cpp
src/network/GameServer.cpp
src/network/GameSession.cpp
src/network/NetworkQualityMonitor.cpp
src/network/PredictionSystem.cpp
src/network/WebSocketProtocol.cpp
)
# Loot system source files
set(LOOT_SOURCES
src/game/LootItem.cpp
src/game/InventorySystem.cpp
src/game/LootTable.cpp
src/game/LootTableManager.cpp
)
# 3D world system
set(WORLD_SOURCES
src/game/WorldChunk.cpp
src/game/WorldGenerator.cpp
src/game/NPCEntity.cpp
src/game/NPCSystem.cpp
src/game/MobSystem.cpp
src/game/GameEntity.cpp
src/game/CollisionSystem.cpp
src/game/LogicWorld.cpp
)
# Core logic system
set(LOGIC_CORE_SOURCES
src/game/LogicCore.cpp
src/game/LogicEntity.cpp
src/game/GameLogic.cpp
src/game/EntityManager.cpp
src/game/SkillSystem.cpp
src/game/Player.cpp
src/game/PlayerManager.cpp
src/game/QuestManager.cpp
)
# Database system
set(DATABASE_SOURCES
src/database/DbManager.cpp
src/database/PostgreSqlClient.cpp
)
if(USE_CITUS)
message(STATUS "Building with Citus support")
list(APPEND DATABASE_SOURCES src/database/CitusClient.cpp)
endif()
if(USE_SQLITE)
message(STATUS "Building with SQLite support")
list(APPEND DATABASE_SOURCES src/database/SQLiteClient.cpp)
endif()
# Include directories
include_directories(
include
${OPENGL_INCLUDE_DIR}
${glm_INCLUDE_DIRS}
${PostgreSQL_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS}
${OPENSSL_INCLUDE_DIR}
)
# Main executable
add_executable(gameserver
src/main.cpp
${CONFIG_SOURCES}
${LOGGING_SOURCES}
${PROCESS_SOURCES}
${SCRIPTING_SOURCES}
${NETWORK_SOURCES}
${LOGIC_CORE_SOURCES}
${LOOT_SOURCES}
${WORLD_SOURCES}
${DATABASE_SOURCES}
)
# Add target-specific preprocessor definitions
if(USE_CITUS)
target_compile_definitions(gameserver PRIVATE USE_CITUS=1)
endif()
if(USE_SQLITE)
target_compile_definitions(gameserver PRIVATE USE_SQLITE=1)
endif()
# Link libraries
target_link_libraries(gameserver PRIVATE
${OPENGL_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
${PostgreSQL_LIBRARIES}
${ZLIB_LIBRARIES}
asio::asio
nlohmann_json::nlohmann_json
OpenSSL::SSL
OpenSSL::Crypto
Python3::Python
fmt::fmt
spdlog::spdlog
${UUID_LIBRARY}
${CRYPT_LIB}
)
if(USE_SQLITE)
target_link_libraries(gameserver PRIVATE SQLite::SQLite3)
endif()
# Compiler flags
if(MSVC)
target_compile_options(gameserver PRIVATE /W4)
else()
target_compile_options(gameserver PRIVATE -Wall -Wextra -pedantic)
endif()
target_link_options(gameserver PRIVATE -Wl,-Bsymbolic)
# Installation
install(TARGETS gameserver DESTINATION bin)
install(DIRECTORY config/ DESTINATION config)
install(DIRECTORY scripts/ DESTINATION scripts)