-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
297 lines (261 loc) · 7.59 KB
/
CMakeLists.txt
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# This file is automatically generated from cmake.toml - DO NOT EDIT
# See https://github.com/build-cpp/cmkr for more information
cmake_minimum_required(VERSION 3.15)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR "In-tree builds are not supported. Run CMake from a separate directory: cmake -B build")
endif()
set(CMKR_ROOT_PROJECT OFF)
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(CMKR_ROOT_PROJECT ON)
# Bootstrap cmkr and automatically regenerate CMakeLists.txt
include(cmkr.cmake OPTIONAL RESULT_VARIABLE CMKR_INCLUDE_RESULT)
if(CMKR_INCLUDE_RESULT)
cmkr()
endif()
# Enable folder support
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Create a configure-time dependency on cmake.toml to improve IDE support
configure_file(cmake.toml cmake.toml COPYONLY)
endif()
project(cs2-plugin)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set(protobuf_USE_EXTERNAL_GTEST OFF)
set(protobuf_USE_EXTERNAL_GTEST OFF)
set(protobuf_BUILD_TESTS OFF)
set(protobuf_BUILD_SHARED_LIBS)
set(EXPECTED_BUILD_TESTS OFF)
add_compile_definitions(_ITERATOR_DEBUG_LEVEL=0)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0)
endif()
if(UNIX AND NOT APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
endif()
include(FetchContent)
# Fix warnings about DOWNLOAD_EXTRACT_TIMESTAMP
if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
endif()
message(STATUS "Fetching spdlog (v1.14.1)...")
FetchContent_Declare(spdlog
GIT_REPOSITORY
"https://github.com/gabime/spdlog"
GIT_TAG
v1.14.1
GIT_SHALLOW
ON
)
FetchContent_MakeAvailable(spdlog)
message(STATUS "Fetching protobuf (0a02547b680a319e73fd04d9efff88d901c3eaa8)...")
FetchContent_Declare(protobuf
GIT_REPOSITORY
"https://github.com/noahbkim/cs2s-protobuf"
GIT_TAG
0a02547b680a319e73fd04d9efff88d901c3eaa8
)
FetchContent_MakeAvailable(protobuf)
option(ZYDIS_BUILD_EXAMPLES "" OFF)
option(ZYDIS_BUILD_TOOLS "" OFF)
option(ZYDIS_BUILD_DOXYGEN "" OFF)
message(STATUS "Fetching Zydis (v4.0.0)...")
FetchContent_Declare(Zydis
GIT_REPOSITORY
"https://github.com/zyantific/zydis.git"
GIT_TAG
v4.0.0
)
FetchContent_MakeAvailable(Zydis)
message(STATUS "Fetching expected (3f0ca7b19253129700a073abfa6d8638d9f7c80c)...")
FetchContent_Declare(expected
GIT_REPOSITORY
"https://github.com/TartanLlama/expected"
GIT_TAG
3f0ca7b19253129700a073abfa6d8638d9f7c80c
)
FetchContent_MakeAvailable(expected)
# Target: mmsdk
add_library(mmsdk INTERFACE)
add_library(mmsdk::mmsdk ALIAS mmsdk)
target_compile_definitions(mmsdk INTERFACE
META_IS_SOURCE2
)
target_include_directories(mmsdk INTERFACE
"metamod-source/core"
"metamod-source/core/sourcehook"
)
# Target: hl2sdk
add_library(hl2sdk INTERFACE)
add_library(hl2sdk::hl2sdk ALIAS hl2sdk)
target_compile_definitions(hl2sdk INTERFACE
PLATFORM_64BITS
)
target_include_directories(hl2sdk INTERFACE
hl2sdk
"hl2sdk/thirdparty/protobuf-3.21.8/src"
"hl2sdk/common"
"hl2sdk/game/shared"
"hl2sdk/game/server"
"hl2sdk/public"
"hl2sdk/public/schemasystem"
"hl2sdk/public/engine"
"hl2sdk/public/mathlib"
"hl2sdk/public/tier0"
"hl2sdk/public/tier1"
"hl2sdk/public/entity2"
"hl2sdk/public/game/server"
)
# Target: plugin
set(plugin_SOURCES
"hl2sdk/tier1/convar.cpp"
"hl2sdk/tier1/generichash.cpp"
"hl2sdk/tier1/keyvalues3.cpp"
"hl2sdk/entity2/entityidentity.cpp"
"hl2sdk/entity2/entitysystem.cpp"
"hl2sdk/entity2/entitykeyvalues.cpp"
"src/addresses.cpp"
"src/gameconfig.cpp"
"src/gamesystem.cpp"
"src/lib/module.linux.cpp"
"src/lib/module.windows.cpp"
"src/lib/pattern.cpp"
"src/modules.cpp"
"src/plugin.cpp"
"src/safetyhook/safetyhook.cpp"
"src/sdk/funcs.cpp"
"src/sdk/schema.cpp"
"src/protobuf/clientmessages.pb.cc"
"src/protobuf/cs_gameevents.pb.cc"
"src/protobuf/cs_usercmd.pb.cc"
"src/protobuf/cstrike15_gcmessages.pb.cc"
"src/protobuf/cstrike15_usermessages.pb.cc"
"src/protobuf/engine_gcmessages.pb.cc"
"src/protobuf/gameevents.pb.cc"
"src/protobuf/gcsdk_gcmessages.pb.cc"
"src/protobuf/netmessages.pb.cc"
"src/protobuf/network_connection.pb.cc"
"src/protobuf/networkbasetypes.pb.cc"
"src/protobuf/steammessages.pb.cc"
"src/protobuf/te.pb.cc"
"src/protobuf/usercmd.pb.cc"
"src/protobuf/usermessages.pb.cc"
"src/addresses.hpp"
"src/gameconfig.hpp"
"src/gamesystem.hpp"
"src/interfaces.hpp"
"src/lib/address.hpp"
"src/lib/fnv1a_hash.hpp"
"src/lib/memory.hpp"
"src/lib/module.hpp"
"src/lib/pattern.hpp"
"src/lib/simd.hpp"
"src/modules.hpp"
"src/plugin.hpp"
"src/safetyhook/safetyhook.hpp"
"src/sdk/funcs.hpp"
"src/sdk/schema.hpp"
"src/protobuf/clientmessages.pb.h"
"src/protobuf/cs_gameevents.pb.h"
"src/protobuf/cs_usercmd.pb.h"
"src/protobuf/cstrike15_gcmessages.pb.h"
"src/protobuf/cstrike15_usermessages.pb.h"
"src/protobuf/engine_gcmessages.pb.h"
"src/protobuf/gameevents.pb.h"
"src/protobuf/gcsdk_gcmessages.pb.h"
"src/protobuf/netmessages.pb.h"
"src/protobuf/network_connection.pb.h"
"src/protobuf/networkbasetypes.pb.h"
"src/protobuf/steammessages.pb.h"
"src/protobuf/te.pb.h"
"src/protobuf/usercmd.pb.h"
"src/protobuf/usermessages.pb.h"
"src/sdk/entity/cbaseentity.h"
"src/sdk/entity/cbasemodelentity.h"
"src/sdk/entity/cbaseplayercontroller.h"
"src/sdk/entity/cbaseplayerpawn.h"
"src/sdk/entity/ccsplayercontroller.h"
"src/sdk/entity/ccsplayerpawn.h"
"src/sdk/entity/ccsweaponbase.h"
"src/sdk/entity/globaltypes.h"
"src/sdk/entity/services.h"
cmake.toml
)
add_library(plugin SHARED)
target_sources(plugin PRIVATE ${plugin_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${plugin_SOURCES})
if(WIN32) # windows
target_compile_definitions(plugin PUBLIC
WIN32
WINDOWS
)
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Linux") # linux
target_compile_definitions(plugin PUBLIC
LINUX
POSIX
_LINUX
PLATFORM_64BITS
)
endif()
if(MSVC) # msvc
target_compile_definitions(plugin PUBLIC
COMPILER_MSVC64
COMPILER_MSVC
NOMINMAX
MSVC
)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "GNU") # gcc
target_compile_definitions(plugin PUBLIC
GCC
COMPILER_GCC
_GLIBCXX_USE_CXX11_ABI=0
)
endif()
if((CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "^MSVC$") OR (CMAKE_C_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_C_COMPILER_FRONTEND_VARIANT MATCHES "^MSVC$")) # clang
target_compile_definitions(plugin PUBLIC
CLANG
COMPILER_CLANG
)
endif()
target_compile_features(plugin PUBLIC
cxx_std_20
)
if(MSVC) # msvc
target_compile_options(plugin PRIVATE
"/MP"
"/permissive-"
"/utf-8"
"/MT$<$<CONFIG:Debug>:d>"
)
endif()
if((CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "^MSVC$") OR (CMAKE_C_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_C_COMPILER_FRONTEND_VARIANT MATCHES "^MSVC$")) # clang
target_compile_options(plugin PRIVATE
-std=libc++
-fPIC
)
endif()
if(WIN32) # windows
target_link_libraries(plugin PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/hl2sdk/lib/public/win64/interfaces.lib"
"${CMAKE_CURRENT_SOURCE_DIR}/hl2sdk/lib/public/win64/tier0.lib"
"${CMAKE_CURRENT_SOURCE_DIR}/hl2sdk/lib/public/win64/tier1.lib"
"${CMAKE_CURRENT_SOURCE_DIR}/hl2sdk/lib/public/win64/mathlib.lib"
)
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Linux") # linux
target_link_libraries(plugin PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/hl2sdk/lib/linux64/interfaces.a"
"${CMAKE_CURRENT_SOURCE_DIR}/hl2sdk/lib/linux64/libtier0.so"
"${CMAKE_CURRENT_SOURCE_DIR}/hl2sdk/lib/linux64/mathlib.a"
"${CMAKE_CURRENT_SOURCE_DIR}/hl2sdk/lib/linux64/tier1.a"
)
endif()
target_link_libraries(plugin PUBLIC
hl2sdk::hl2sdk
mmsdk::mmsdk
spdlog::spdlog
libprotobuf
Zydis
tl::expected
)