-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
462 lines (394 loc) · 19.6 KB
/
Copy pathCMakeLists.txt
File metadata and controls
462 lines (394 loc) · 19.6 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
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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
cmake_minimum_required(VERSION 4.0.0)
# Suppress vcpkg root mismatch warning
unset(ENV{VCPKG_ROOT})
# Suppress vcpkg usage text spam
set(X_VCPKG_APPLOCAL_DEPS_INSTALL OFF CACHE BOOL "" FORCE)
set(VCPKG_INSTALL_OPTIONS "--no-print-usage" CACHE STRING "" FORCE)
set(Z_VCPKG_BUILTIN_POWERSHELL_PATH "" CACHE STRING "" FORCE)
# Suppress vcpkg install output
function(message)
list(GET ARGV 0 MessageType)
if(MessageType STREQUAL "STATUS")
list(GET ARGV 1 MessageText)
# Suppress vcpkg installation messages
if(MessageText MATCHES "^Running vcpkg install" OR
MessageText MATCHES "^The following packages" OR
MessageText MATCHES "^\\*" OR
MessageText MATCHES "^ " OR
MessageText MATCHES "^All requested installations completed")
return()
endif()
endif()
_message(${ARGV})
endfunction()
# Project Name
project(NEVRServer LANGUAGES C CXX)
# import the version from the git-version.cmake file
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/set_project_version_from_git.cmake")
# Set PROJECT_VERSION and GIT_COMMIT_HASH based on the current git state.
set_project_version_from_git()
# Define the version and git hash as compile definitions
add_compile_definitions(
PROJECT_VERSION_MAJOR="${PROJECT_VERSION_MAJOR}"
PROJECT_VERSION_MINOR="${PROJECT_VERSION_MINOR}"
PROJECT_VERSION_PATCH="${PROJECT_VERSION_PATCH}"
PROJECT_VERSION_TWEAK="${PROJECT_VERSION_TWEAK}"
PROJECT_VERSION="${PROJECT_VERSION}"
GIT_COMMIT_HASH="${GIT_COMMIT_HASH}"
GIT_DESCRIBE="${GIT_DESCRIBE}")
# Print out the version that was set by set_project_version_from_git()
message(STATUS "Project version: ${PROJECT_VERSION} (${GIT_COMMIT_HASH})")
# Set the project output name
set(PROJECT_OUTPUT_NAME "${CMAKE_PROJECT_NAME}")
# Set the project description
set(PROJECT_DESCRIPTION "NEVR Game Server")
# Set the project vendor
set(PROJECT_VENDOR "EchoTools")
# Set the project organization
set(PROJECT_ORGANIZATION "EchoTools")
# Set the project URL
set(PROJECT_URL "https://github.com/echotools/nevr-runtime")
# set(CMAKE_BUILD_TYPE "Release")
# Check if the CMAKE_BUILD_TYPE is set, if not, default to Debug
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
endif()
message(STATUS "Build type set to: ${CMAKE_BUILD_TYPE}")
# Disable verbose makefile output
set(CMAKE_VERBOSE_MAKEFILE OFF)
# Set the CMake generator to Ninja
set(CMAKE_GENERATOR "Ninja")
# Set the CMake executable linker flags (MSVC only)
if(MSVC)
set(CMAKE_EXE_LINKER_FLAGS "/SUBSYSTEM:WINDOWS")
endif()
# Set the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# MSVC-specific settings
if(MSVC)
# Add LTO for Release
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON)
# Disable UAC
add_link_options(/MANIFESTUAC:NO)
# Enforce Static Runtime Libraries
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded")
endif()
# Set the output directories
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
# Enable CMake to generate compile_commands.json
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# MSVC-specific compile options
if(MSVC)
add_compile_options(
"/Zi" # Enable debugging information
"/W3" # Warning level 3
"/sdl" # Enable additional security checks
"/permissive-" # Enforce standard conformance
"/MT" # Use static runtime library
"/EHsc" # Enable C++ exceptions
"$<$<CONFIG:Debug>:/D_DEBUG>" # Debug: Define _DEBUG
"$<$<CONFIG:Release>:/DNDEBUG>" # Release: Define NDEBUG
"$<$<CONFIG:Release>:/Od>" # Debug: Disable optimizations
# "$<$<CONFIG:Release>:/O2>" # Release: Enable optimizations
)
endif()
# MinGW-specific compile options
if(MINGW)
add_compile_options(
-Wall
-Wextra
# Disable specific warnings that are unavoidable in this codebase
-Wno-unknown-pragmas # Windows-specific pragmas like #pragma comment
-Wno-unused-parameter # DLL export functions have required but unused params
-Wno-cast-function-type # Windows API requires function pointer casts
-Wno-sign-compare # Mixing signed/unsigned in legacy loops
-Wno-maybe-uninitialized # False positives on struct initialization
-Wno-pragma-once-outside-header # .cpp files misused as headers in legacy code
"$<$<CONFIG:Debug>:-g>"
"$<$<CONFIG:Debug>:-O0>"
"$<$<CONFIG:Release>:-O3>"
"$<$<CONFIG:Release>:-DNDEBUG>"
)
# C++-only warning suppressions
add_compile_options(
"$<$<COMPILE_LANGUAGE:CXX>:-Wno-conversion-null>" # NULL to UINT64 conversions in legacy code
"$<$<COMPILE_LANGUAGE:CXX>:-Wno-delete-non-virtual-dtor>" # Game engine interface has no virtual dtor
"$<$<COMPILE_LANGUAGE:CXX>:-Wno-reorder>" # Member initialization order in legacy code
)
endif()
# MSVC-specific link options
if(MSVC)
add_link_options(
"$<$<CONFIG:Debug>:/DEBUG>" # Debug: Generate debug information
"$<$<CONFIG:Debug>:/SUBSYSTEM:WINDOWS>" # Debug: Set subsystem to Windows
"$<$<CONFIG:Release>:/DEBUG>" # Debug: Generate debug information
"$<$<CONFIG:Release>:/SUBSYSTEM:WINDOWS>" # Release: Set subsystem to Windows
"$<$<CONFIG:Release>:/OPT:REF>" # Release: Enable reference optimization
"$<$<CONFIG:Release>:/OPT:ICF>" # Release: Enable identical COMDAT folding
)
endif()
# MinGW-specific link options
if(MINGW)
add_link_options(
-mwindows
-static
-static-libgcc
-static-libstdc++
)
endif()
# Include directories
include_directories(
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR}
"${CMAKE_SOURCE_DIR}/src")
# Define preprocessor macros
add_compile_definitions("$<$<CONFIG:Debug>:_DEBUG;_WINDOWS;_USRDLL>"
"$<$<CONFIG:Release>:NDEBUG;_WINDOWS;_USRDLL>")
add_subdirectory(extern)
find_package(Protobuf REQUIRED)
add_subdirectory(src/common)
add_subdirectory(src/nevr_api)
add_subdirectory(src/gamepatches)
add_subdirectory(src/modules/platform-compat)
add_subdirectory(src/modules/token-auth)
add_subdirectory(src/modules/ws-bridge)
add_subdirectory(src/legacy/gamepatches)
# add_subdirectory(src/gameserver) # merged into gamepatches
add_subdirectory(src/pnsrad)
add_subdirectory(src/legacy/gameserver)
# telemetryagent moved to extras/ — needs protobuf-lite refactor before reintegration
add_subdirectory(src/libovr-stub)
add_subdirectory(plugins)
# =============================================================================
# Optional drop-in build modules (modules/*/CMakeLists.txt)
# =============================================================================
# Each subdirectory under modules/ that contains a CMakeLists.txt is
# auto-discovered here and added via add_subdirectory(). No-op when modules/
# is empty or absent. See modules/README.md.
# =============================================================================
file(GLOB NEVR_MODULE_LISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/*/CMakeLists.txt")
foreach(module_list ${NEVR_MODULE_LISTS})
get_filename_component(module_dir "${module_list}" DIRECTORY)
get_filename_component(module_name "${module_dir}" NAME)
message(STATUS "[modules] adding ${module_name}")
add_subdirectory("${module_dir}")
endforeach()
# Include a local cmake script if it exists
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/local.cmake")
# include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/local.cmake")
endif()
# =============================================================================
# Distribution Package Target
# =============================================================================
# Creates distribution archives (tar.zst and zip) containing DLLs and scripts
# Usage: cmake --build <build_dir> --target dist
# =============================================================================
set(DIST_NAME "nevr-runtime-v${PROJECT_VERSION}")
set(DIST_DIR "${CMAKE_SOURCE_DIR}/dist/${DIST_NAME}")
# List of DLL artifacts to include
set(DIST_DLLS
"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/BugSplat64.dll"
# "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/gameserver.dll" # merged into gamepatches
)
# List of debug symbol files to include
set(DIST_DBG_FILES
"${CMAKE_BINARY_DIR}/BugSplat64.dll.dbg"
# "${CMAKE_BINARY_DIR}/gameserver.dll.dbg" # merged into gamepatches
)
# Custom target to prepare distribution directory
add_custom_target(dist-prepare
COMMAND ${CMAKE_COMMAND} -E rm -rf "${CMAKE_SOURCE_DIR}/dist"
COMMAND ${CMAKE_COMMAND} -E make_directory "${DIST_DIR}"
# BugSplat64.dll — NEVR runtime (replaces the original crash reporter DLL).
# The game statically imports it, so it loads at process startup before WinMain.
COMMAND test -f "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/BugSplat64.dll" && ${CMAKE_COMMAND} -E copy "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/BugSplat64.dll" "${DIST_DIR}/BugSplat64.dll" || true
# gameserver.dll merged into gamepatches — no separate DLL to copy
# COMMAND test -f "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/gameserver.dll" && ${CMAKE_COMMAND} -E copy "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/gameserver.dll" "${DIST_DIR}/pnsradgameserver.dll" || true
# Copy pnsrad.dll (if exists)
COMMAND test -f "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/pnsrad.dll" && ${CMAKE_COMMAND} -E copy "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/pnsrad.dll" "${DIST_DIR}/pnsrad.dll" || true
# Launcher executables — not built yet (module-extraction infrastructure present but launchers not wired)
COMMAND test -f "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/echovr_launcher.exe" && ${CMAKE_COMMAND} -E copy "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/echovr_launcher.exe" "${DIST_DIR}/echovr.exe" || true
COMMAND test -f "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/echovr_server.exe" && ${CMAKE_COMMAND} -E copy "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/echovr_server.exe" "${DIST_DIR}/echovr_server.exe" || true
COMMAND test -f "${CMAKE_SOURCE_DIR}/README.md" && ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/README.md" "${DIST_DIR}/" || true
# Copy plugin DLLs into plugins/ subdirectory
COMMAND ${CMAKE_COMMAND} -E make_directory "${DIST_DIR}/plugins"
COMMAND test -f "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/log_filter.dll" && ${CMAKE_COMMAND} -E copy "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/log_filter.dll" "${DIST_DIR}/plugins/" || true
COMMAND test -f "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/broadcaster_bridge.dll" && ${CMAKE_COMMAND} -E copy "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/broadcaster_bridge.dll" "${DIST_DIR}/plugins/" || true
COMMAND test -f "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/anim_debugger.dll" && ${CMAKE_COMMAND} -E copy "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/anim_debugger.dll" "${DIST_DIR}/plugins/" || true
VERBATIM
)
# =============================================================================
# Code Signing
# =============================================================================
# Signs DLLs/EXEs in the distribution directory using osslsigncode (Linux) or
# signtool (Windows). Credentials are configured via environment variables:
# CODESIGN_PFX / CODESIGN_CERT+CODESIGN_KEY / CODESIGN_THUMBPRINT
# Skips gracefully when no credentials are available (default for local builds).
# Set CODESIGN_SKIP=1 to skip explicitly, or provide credentials to enable.
# =============================================================================
find_program(OSSLSIGNCODE osslsigncode)
set(CODESIGN_SCRIPT "${CMAKE_SOURCE_DIR}/cmake/codesign/sign.sh")
# Collect signable artifacts in dist dir (DLLs and EXEs)
set(DIST_SIGN_GLOB "${DIST_DIR}/*.dll" "${DIST_DIR}/*.exe")
if(OSSLSIGNCODE)
add_custom_target(dist-sign
COMMAND bash -c "\"${CODESIGN_SCRIPT}\" \"${DIST_DIR}/\"*.dll \"${DIST_DIR}/\"*.exe \"${DIST_DIR}/plugins/\"*.dll"
DEPENDS dist-prepare
COMMENT "Code signing distribution artifacts"
)
else()
add_custom_target(dist-sign
COMMAND ${CMAKE_COMMAND} -E echo "WARNING: osslsigncode not found, skipping code signing"
DEPENDS dist-prepare
VERBATIM
)
endif()
# Create tar.zst archive
add_custom_target(dist-tar
COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_SOURCE_DIR}/dist"
tar --zstd -cf "${CMAKE_SOURCE_DIR}/dist/${DIST_NAME}.tar.zst" "${DIST_NAME}"
DEPENDS dist-sign
VERBATIM
)
# Create zip archive
add_custom_target(dist-zip
COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_SOURCE_DIR}/dist"
${CMAKE_COMMAND} -E tar cf "${CMAKE_SOURCE_DIR}/dist/${DIST_NAME}.zip" --format=zip "${DIST_NAME}"
DEPENDS dist-sign
VERBATIM
)
# Main distribution target that creates both archives
add_custom_target(dist
DEPENDS dist-tar dist-zip
)
# =============================================================================
# Lite Distribution Package Target (stripped, no debug symbols)
# =============================================================================
# Creates smaller distribution archives without debug symbols
# Usage: cmake --build <build_dir> --target dist-lite
# =============================================================================
set(DIST_LITE_NAME "nevr-runtime-v${PROJECT_VERSION}-lite")
set(DIST_LITE_DIR "${CMAKE_SOURCE_DIR}/dist/${DIST_LITE_NAME}")
# Find strip tool (use llvm-strip or strip)
find_program(STRIP_TOOL NAMES llvm-strip strip)
# Custom target to prepare lite distribution directory with stripped DLLs
add_custom_target(dist-lite-prepare
COMMAND ${CMAKE_COMMAND} -E rm -rf "${DIST_LITE_DIR}"
COMMAND ${CMAKE_COMMAND} -E make_directory "${DIST_LITE_DIR}"
# Copy gamepatches.dll + legacy dbgcore.dll alias, then strip
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/BugSplat64.dll" "${DIST_LITE_DIR}/BugSplat64.dll" && ${STRIP_TOOL} --strip-all "${DIST_LITE_DIR}/BugSplat64.dll" || ${CMAKE_COMMAND} -E true
# gameserver.dll merged into gamepatches — no separate DLL to copy
# COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/gameserver.dll" "${DIST_LITE_DIR}/pnsradgameserver.dll" && ${STRIP_TOOL} --strip-all "${DIST_LITE_DIR}/pnsradgameserver.dll" || ${CMAKE_COMMAND} -E true
# Copy pnsrad.dll and strip (if exists)
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/pnsrad.dll" "${DIST_LITE_DIR}/pnsrad.dll" && ${STRIP_TOOL} --strip-all "${DIST_LITE_DIR}/pnsrad.dll" || ${CMAKE_COMMAND} -E true
# Launcher executables — not built yet (module-extraction infrastructure present but launchers not wired)
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/echovr_launcher.exe" "${DIST_LITE_DIR}/echovr.exe" || ${CMAKE_COMMAND} -E true
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/echovr_server.exe" "${DIST_LITE_DIR}/echovr_server.exe" || ${CMAKE_COMMAND} -E true
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/README.md" "${DIST_LITE_DIR}/" || ${CMAKE_COMMAND} -E true
# Copy and strip plugin DLLs into plugins/ subdirectory
COMMAND ${CMAKE_COMMAND} -E make_directory "${DIST_LITE_DIR}/plugins"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/log_filter.dll" "${DIST_LITE_DIR}/plugins/" && ${STRIP_TOOL} --strip-all "${DIST_LITE_DIR}/plugins/log_filter.dll" || ${CMAKE_COMMAND} -E true
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/broadcaster_bridge.dll" "${DIST_LITE_DIR}/plugins/" && ${STRIP_TOOL} --strip-all "${DIST_LITE_DIR}/plugins/broadcaster_bridge.dll" || ${CMAKE_COMMAND} -E true
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/anim_debugger.dll" "${DIST_LITE_DIR}/plugins/" && ${STRIP_TOOL} --strip-all "${DIST_LITE_DIR}/plugins/anim_debugger.dll" || ${CMAKE_COMMAND} -E true
COMMENT "Preparing lite distribution directory (stripped): ${DIST_LITE_DIR}"
VERBATIM
)
# Sign lite distribution artifacts
if(OSSLSIGNCODE)
add_custom_target(dist-lite-sign
COMMAND bash -c "\"${CODESIGN_SCRIPT}\" \"${DIST_LITE_DIR}/\"*.dll \"${DIST_LITE_DIR}/\"*.exe \"${DIST_LITE_DIR}/plugins/\"*.dll"
DEPENDS dist-lite-prepare
COMMENT "Code signing lite distribution artifacts"
)
else()
add_custom_target(dist-lite-sign
COMMAND ${CMAKE_COMMAND} -E echo "WARNING: osslsigncode not found, skipping code signing"
DEPENDS dist-lite-prepare
VERBATIM
)
endif()
# Create lite tar.zst archive
add_custom_target(dist-lite-tar
COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_SOURCE_DIR}/dist"
tar --zstd -cvf "${CMAKE_SOURCE_DIR}/dist/${DIST_LITE_NAME}.tar.zst" "${DIST_LITE_NAME}"
DEPENDS dist-lite-sign
COMMENT "Creating ${DIST_LITE_NAME}.tar.zst"
VERBATIM
)
# Create lite zip archive
add_custom_target(dist-lite-zip
COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_SOURCE_DIR}/dist"
${CMAKE_COMMAND} -E tar cvf "${CMAKE_SOURCE_DIR}/dist/${DIST_LITE_NAME}.zip" --format=zip "${DIST_LITE_NAME}"
DEPENDS dist-lite-sign
COMMENT "Creating ${DIST_LITE_NAME}.zip"
VERBATIM
)
# Main lite distribution target that creates both archives
add_custom_target(dist-lite
DEPENDS dist-lite-tar dist-lite-zip
COMMENT "Lite distribution packages created: ${DIST_LITE_NAME}.tar.zst and ${DIST_LITE_NAME}.zip"
)
# Print lite distribution info
add_custom_command(TARGET dist-lite POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo ""
COMMAND ${CMAKE_COMMAND} -E echo "========================================"
COMMAND ${CMAKE_COMMAND} -E echo "Lite distribution packages created (stripped, no debug symbols):"
COMMAND ${CMAKE_COMMAND} -E echo " ${CMAKE_SOURCE_DIR}/dist/${DIST_LITE_NAME}.tar.zst"
COMMAND ${CMAKE_COMMAND} -E echo " ${CMAKE_SOURCE_DIR}/dist/${DIST_LITE_NAME}.zip"
COMMAND ${CMAKE_COMMAND} -E echo "========================================"
VERBATIM
)
# =============================================================================
# Legacy Distribution Package Target
# =============================================================================
# Creates distribution archives containing only legacy DLLs (v1 implementations)
# Usage: cmake --build <build_dir> --target dist-legacy
# =============================================================================
set(DIST_LEGACY_NAME "nevr-runtime-v${PROJECT_VERSION}-legacy")
set(DIST_LEGACY_DIR "${CMAKE_SOURCE_DIR}/dist/${DIST_LEGACY_NAME}")
add_custom_target(dist-legacy-prepare
COMMAND ${CMAKE_COMMAND} -E make_directory "${DIST_LEGACY_DIR}"
COMMAND test -f "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/gamepatcheslegacy.dll" && ${CMAKE_COMMAND} -E copy "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/gamepatcheslegacy.dll" "${DIST_LEGACY_DIR}/" || true
COMMAND test -f "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/gameserverlegacy.dll" && ${CMAKE_COMMAND} -E copy "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/gameserverlegacy.dll" "${DIST_LEGACY_DIR}/" || true
COMMENT "Preparing legacy distribution directory: ${DIST_LEGACY_DIR}"
VERBATIM
)
if(OSSLSIGNCODE)
add_custom_target(dist-legacy-sign
COMMAND bash -c "\"${CODESIGN_SCRIPT}\" \"${DIST_LEGACY_DIR}/\"*.dll"
DEPENDS dist-legacy-prepare
COMMENT "Code signing legacy distribution artifacts"
)
else()
add_custom_target(dist-legacy-sign
COMMAND ${CMAKE_COMMAND} -E echo "WARNING: osslsigncode not found, skipping code signing"
DEPENDS dist-legacy-prepare
VERBATIM
)
endif()
add_custom_target(dist-legacy-tar
COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_SOURCE_DIR}/dist"
tar --zstd -cf "${CMAKE_SOURCE_DIR}/dist/${DIST_LEGACY_NAME}.tar.zst" "${DIST_LEGACY_NAME}"
DEPENDS dist-legacy-sign
COMMENT "Creating ${DIST_LEGACY_NAME}.tar.zst"
VERBATIM
)
add_custom_target(dist-legacy-zip
COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_SOURCE_DIR}/dist"
${CMAKE_COMMAND} -E tar cf "${CMAKE_SOURCE_DIR}/dist/${DIST_LEGACY_NAME}.zip" --format=zip "${DIST_LEGACY_NAME}"
DEPENDS dist-legacy-sign
COMMENT "Creating ${DIST_LEGACY_NAME}.zip"
VERBATIM
)
add_custom_target(dist-legacy
DEPENDS dist-legacy-tar dist-legacy-zip
COMMENT "Legacy distribution packages created: ${DIST_LEGACY_NAME}.tar.zst and ${DIST_LEGACY_NAME}.zip"
)
# =============================================================================
# Combined dist-all target
# =============================================================================
add_custom_target(dist-all
DEPENDS dist dist-lite dist-legacy
COMMENT "All distribution packages created"
)