-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
586 lines (490 loc) · 20.5 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
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
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
#-------------------------------------------------------------------
# Setup CMake Policies
#-------------------------------------------------------------------
# Policy CMP0074 is required to let find_package() use <PackageName>_ROOT variables.
# https://cmake.org/cmake/help/git-stage/policy/CMP0074.html
if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif()
# Policy CMP0091 is required to enable MSVC_RUNTIME_LIBRARY property.
# This needs to be set before the first project for the policy to have an effect.
# https://cmake.org/cmake/help/git-stage/policy/CMP0091.html
if(POLICY CMP0091)
cmake_policy(SET CMP0091 NEW)
endif()
# Policy CMP0069 is required for INTERPROCEDURAL_OPTIMIZATION
# https://cmake.org/cmake/help/git-stage/policy/CMP0069.html
if(POLICY CMP0069)
cmake_policy(SET CMP0069 NEW)
endif()
#-------------------------------------------------------------------
# CMake Project
#-------------------------------------------------------------------
# vcpkg.json is the primary source for version data
file(READ ${CMAKE_SOURCE_DIR}/vcpkg.json VCPKG_JSON_STRING)
string(JSON APP_VERSION GET ${VCPKG_JSON_STRING} "version")
project(csgo_cli VERSION ${APP_VERSION} LANGUAGES CXX)
# inject version data into version header
# write to build folder (not to source folder!)
configure_file(
"${PROJECT_SOURCE_DIR}/src/VersionAndConstants.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/src/VersionAndConstants.h"
)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/src)
#-------------------------------------------------------------------
# Setup CMake Includes
#-------------------------------------------------------------------
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
include(FindPackageHandleStandardArgs)
include(ShowBuildTargetProperties)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
#-------------------------------------------------------------------
# Setup Dependency Manager: VCPKG
#-------------------------------------------------------------------
include(setup-vcpkg)
# ==================================================================================================
# Options
# ==================================================================================================
option(BUILD_SHARED_LIBS "Build shared or static libs" OFF)
option(ENABLE_LTO "Enable link-time optimizations if supported by the compiler" ON)
option(ENABLE_ASAN "Enable address sanitizer (ASAN)" OFF)
option(BUILD_TESTS "Build tests" ON)
# ==================================================================================================
# Link time optimizations (LTO)
# ==================================================================================================
if (ENABLE_LTO)
# https://cmake.org/cmake/help/git-stage/policy/CMP0069.html
if(POLICY CMP0069)
cmake_policy(SET CMP0069 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
endif()
include(CheckIPOSupported)
check_ipo_supported(RESULT IPO_SUPPORT OUTPUT IPO_OUTPUT)
if (IPO_SUPPORT)
message(STATUS "[INFO] Link time optimizations (LTO) is ON.")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
message(WARNING "[INFO] Link time optimizations (LTO) is not supported: ${IPO_OUTPUT}")
endif()
if(MSVC)
# CMake IPO doesn't set the LTCG flag, which causes the linker to restart
add_link_options($<$<BOOL:${CMAKE_INTERPROCEDURAL_OPTIMIZATION}>:/LTCG>)
endif()
endif()
# ==================================================================================================
# OS specific
# ==================================================================================================
if (WIN32)
# Build for a Windows 10 host system.
set(CMAKE_SYSTEM_VERSION 10.0)
message(STATUS "[INFO] BUILD_SHARED_LIBS -> '${BUILD_SHARED_LIBS}'.")
# When we build statically (MT):
if(NOT BUILD_SHARED_LIBS)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
endif()
# ==================================================================================================
# Compiler flags
# ==================================================================================================
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
message(STATUS "\n-- Compiler and platform toolset:\n")
# Report compiler and platform toolset
message(STATUS "USING COMPILER: ${CMAKE_CXX_COMPILER_ID}")
message(STATUS "MSVC_VERSION: ${MSVC_VERSION}")
message(STATUS "MSVC_TOOLSET_VERSION: ${MSVC_TOOLSET_VERSION}")
message(STATUS "CMAKE_MSVC_RUNTIME_LIBRARY: ${CMAKE_MSVC_RUNTIME_LIBRARY}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++latest")
# MSVC warning suppressions
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
add_definitions(-D_SILENCE_CXX20_IS_POD_DEPRECATION_WARNING) # protobuf triggers this warning
add_definitions(-DNOMINMAX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /permissive-")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /nologo")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /LARGEADDRESSAWARE") # Allow more than 2 GB in 32 bit application.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4146") # Warning C4146: unary minus operator applied to unsigned type, result still unsigned
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4244") # Warning C4244: 'initializing': conversion from 'double' to 'int', possible loss of data
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267") # Warning C4267: 'var' : conversion from 'size_t' to 'type', possible loss of data
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4305") # Warning C4305: 'initializing': truncation from 'double' to 'float'
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4800") # Warning C4800: 'uint32_t' : forcing value to bool 'true' or 'false' (performance warning)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4838") # Warning C4838: conversion from 'double' to 'float' requires a narrowing conversion
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4996") # Warning C4996: Call to 'function' with parameters that may be unsafe
# You don't want to know why.
# https://github.com/protocolbuffers/protobuf/blob/master/cmake/README.md#notes-on-compiler-warnings
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4251") # Warning C4251: 'identifier': class 'type' needs to have dll-interface to be used by clients of class 'type2'
# /EHsc: Specifies the model of exception handling.
# /GL: Enables whole program optimization.
# /Gm: Enable minimal rebuilds; conflicts with /MP
# /GS: Buffers security check.
# /MD: Creates a multi-threaded DLL using MSVCRT.lib.
# /MDd: Creates a debug multi-threaded DLL using MSVCRTD.lib.
# /O2: Creates fast code.
# /Od: Disables optimization.
# /Oi: Generates intrinsic functions.
# /RTC1: Enables run-time error checking.
# /W4: Sets which warning level to output.
# /Zi: Generates complete debugging information.
# /JMC: Just my code enables the VS debugger to step over internal (system, framework, library, and other non-user) calls.
set(CMAKE_CXX_FLAGS "/EHsc /GS /Zi /Gm-") #/W4
set(CMAKE_CXX_FLAGS_DEBUG "/Od /RTC1 /JMC")
set(CMAKE_CXX_FLAGS_RELEASE "/GL /O2 /Oi")
message(STATUS "USING THESE CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# MSVC warning suppressions
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
add_definitions(-D_SILENCE_CXX20_IS_POD_DEPRECATION_WARNING) # protobuf triggers this warning
add_definitions(-DNOMINMAX)
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ ") # -lc++abi
endif()
# /MP: build with multiple processors
# https://docs.microsoft.com/en-us/cpp/build/reference/mp-build-with-multiple-processes?view=msvc-160
if(CMAKE_GENERATOR MATCHES "Visual Studio" AND CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
if(CMake_MSVC_PARALLEL)
if(CMake_MSVC_PARALLEL GREATER 0)
string(APPEND CMAKE_C_FLAGS " /MP${CMake_MSVC_PARALLEL}")
string(APPEND CMAKE_CXX_FLAGS " /MP${CMake_MSVC_PARALLEL}")
else()
string(APPEND CMAKE_C_FLAGS " /MP")
string(APPEND CMAKE_CXX_FLAGS " /MP")
endif()
endif()
endif()
# ==================================================================================================
# Linker flags
# ==================================================================================================
# Link static runtime libraries
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") # /MD
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
add_link_options("/nologo")
add_link_options("/VERBOSE:LIB")
endif()
# ==================================================================================================
# Setup Dependencies
# ==================================================================================================
message(STATUS "\n-- Dependencies:\n")
#
# Steamworks SDK
#
set(STEAMWORKS_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/dependencies/sw_sdk/public")
set(STEAMWORKS_REDISTBIN_DIR "${CMAKE_SOURCE_DIR}/dependencies/sw_sdk/redistributable_bin")
configure_file("${CMAKE_SOURCE_DIR}/resources/steam_appid.txt" "steam_appid.txt" COPYONLY)
if(WIN32)
set(STEAMWORKS_LIBRARY "${STEAMWORKS_REDISTBIN_DIR}/win64/steam_api64.lib")
configure_file("${STEAMWORKS_REDISTBIN_DIR}/win64/steam_api64.dll" "steam_api64.dll" COPYONLY)
else()
set(STEAMWORKS_LIBRARY "${STEAMWORKS_REDISTBIN_DIR}/linux64/libsteam_api.so")
configure_file("${STEAMWORKS_LIBRARY}" "libsteam_api.so" COPYONLY)
endif()
find_package(Steamworks REQUIRED)
#
# Google Protobuf
#
set(protobuf_MSVC_STATIC_RUNTIME on)
if(MSVC AND protobuf_MSVC_STATIC_RUNTIME)
set(CompilerFlags
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELWITHDEBINFO
)
foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
set(${CompilerFlag} "${${CompilerFlag}}" CACHE STRING "msvc compiler flags" FORCE)
message("MSVC flags: ${CompilerFlag}: ${${CompilerFlag}}")
endforeach()
endif()
#
# Protobuf is non-trivial to include.
#
set(Protobuf_USE_STATIC_LIBS ON)
set(Protobuf_DIR "${VCPKG_DIR}/share/protobuf")
list(APPEND CMAKE_PREFIX_PATH "${VCPKG_DIR}/tools/protobuf")
#
# Please fix your protobuf_generate(), okay?
# https://stackoverflow.com/questions/52533396/cmake-cant-find-protobuf-protobuf-generate-cpp
#
set(protobuf_MODULE_COMPATIBLE ON CACHE BOOL "")
find_program(Protobuf_PROTOC_EXECUTABLE
NAMES protoc
DOC "Google Protocol Buffers Compiler"
PATHS
"${VCPKG_DIR}/tools/protobuf"
"${VCPKG_ROOT}/packages/protobuf_${VCPKG_TARGET_TRIPLET}/tools/protobuf"
)
if(NOT Protobuf_PROTOC_EXECUTABLE)
if(WIN32)
set(PROTOC "${VCPKG_DIR}/tools/protobuf/protoc.exe")
set(Protobuf_PROTOC_EXECUTABLE "${VCPKG_DIR}/tools/protobuf/protoc.exe")
else()
set(PROTOC "${VCPKG_DIR}/tools/protobuf/protoc")
set(Protobuf_PROTOC_EXECUTABLE "${VCPKG_DIR}/tools/protobuf/protoc")
endif()
endif()
message(STATUS "Found protoc: ${Protobuf_PROTOC_EXECUTABLE}")
# Find Protobuf package
find_package(Protobuf CONFIG REQUIRED)
#
# SteamDatabase Protobufs Data Files
#
include(FetchContent)
# Define the repository and the destination directory
FetchContent_Declare(steamdatabase_protobufs
GIT_REPOSITORY "https://github.com/SteamDatabase/Protobufs.git"
GIT_TAG "origin/master"
)
FetchContent_MakeAvailable(steamdatabase_protobufs)
message("--[CSGO Protobuf] Fetched SteamDatabase Protobufs Data Files to steamdatabase_protobufs_SOURCE_DIR: ${steamdatabase_protobufs_SOURCE_DIR}")
# Patch CSGO Protobufs
# After patch was applied ${Protobuf_INCLUDE_DIRS} should contain the file "patch_applied_marker".
include(PatchCsGoProtobufs)
if(NOT EXISTS "${steamdatabase_protobufs_SOURCE_DIR}/csgo/patch_applied_marker")
patch_csgo_protobufs()
else()
message("--[CSGO Protobuf] Already patched. Skipping.")
endif()
# let the custom target depend on the patching run
add_custom_target(patch_steamdatabase_csgo_protobufs ALL DEPENDS "${steamdatabase_protobufs_SOURCE_DIR}/csgo/patch_applied_marker")
#
# Compile CS:GO Protobufs (proto -> cpp)
#
protobuf_generate_cpp(PROTO_ENGINE_GCMESSAGES_SRC PROTO_ENGINE_GCMESSAGES_HDR
${steamdatabase_protobufs_SOURCE_DIR}/csgo/engine_gcmessages.proto
)
protobuf_generate_cpp(PROTO_CSTRIKE15_GCMESSAGES_SRC PROTO_CSTRIKE15_GCMESSAGES_HDR
${steamdatabase_protobufs_SOURCE_DIR}/csgo/cstrike15_gcmessages.proto
)
protobuf_generate_cpp(PROTO_STEAMMESSAGES_SRC PROTO_STEAMMESSAGES_HDR
${steamdatabase_protobufs_SOURCE_DIR}/csgo/steammessages.proto
)
protobuf_generate_cpp(PROTO_GCSDK_GCMESSAGES_SRC PROTO_GCSDK_GCMESSAGES_HDR
${steamdatabase_protobufs_SOURCE_DIR}/csgo/gcsdk_gcmessages.proto
)
protobuf_generate_cpp(PROTO_GCSYSTEMMSGS_SRC PROTO_GCSYSTEMMSGS_HDR
${steamdatabase_protobufs_SOURCE_DIR}/csgo/gcsystemmsgs.proto
)
#
# zlib
#
set(ZLIB_ROOT "${VCPKG_DIR}")
find_package(ZLIB REQUIRED)
#
# Curl
#
set(CURL_DIR "${VCPKG_DIR}/share/curl")
find_package(CURL CONFIG REQUIRED)
#
# Download "cacert.pem" for Curl -> "curl-ca-bundle.crt"
#
if(NOT EXISTS "${CMAKE_BINARY_DIR}/curl-ca-bundle.crt")
message(STATUS "Downloading: https://curl.haxx.se/ca/cacert.pem -> curl-ca-bundle.crt")
file(DOWNLOAD "https://curl.haxx.se/ca/cacert.pem" "${CMAKE_BINARY_DIR}/curl-ca-bundle.crt" TLS_VERIFY ON)
endif()
#
# FMT
#
set(fmt_DIR "${VCPKG_DIR}/share/fmt")
find_package(fmt CONFIG REQUIRED)
#
# nlohman-json
#
set(nlohmann_json_DIR "${VCPKG_DIR}/share/nlohmann_json")
find_package(nlohmann_json CONFIG REQUIRED)
#
# spdlog
#
set(spdlog_DIR "${VCPKG_DIR}/share/spdlog")
find_package(spdlog CONFIG REQUIRED)
#
# Copy Additional Files
#
configure_file("${CMAKE_SOURCE_DIR}/README.md" "readme.txt" COPYONLY)
configure_file("${CMAKE_SOURCE_DIR}/LICENSE" "license.txt" COPYONLY)
configure_file("${CMAKE_SOURCE_DIR}/resources/update.bat" "update.bat" COPYONLY)
#
# Add Resources to Executable
#
if(WIN32)
set(ADDITIONAL_RESOURCES "resources/CSGO_CLI.rc")
else()
set(ADDITIONAL_RESOURCES "")
endif()
#-------------------------------------------------------------------
# Build Target: csgo_cli_lib (library)
#-------------------------------------------------------------------
add_library(csgo_cli_lib
# base
src/DataObject.h
src/DataObject.cpp
src/DateTimeUtils.h
src/DateTimeUtils.cpp
src/ErrorHandler.h
src/ExceptionHandler.h
src/ExceptionHandler.cpp
src/ShareCode.h
src/ShareCode.cpp
src/SteamId.h
src/SteamId.cpp
src/VersionAndConstants.h # = ${CMAKE_CURRENT_BINARY_DIR}/src/VersionAndConstants.h
# commands
src/commands/cmd.help.h
src/commands/cmd.help.cpp
src/commands/cmd.user.h
src/commands/cmd.user.cpp
src/commands/cmd.upload.h
src/commands/cmd.upload.cpp
src/commands/cmd.matches.h
src/commands/cmd.matches.cpp
src/commands/cmd.scoreboard.h
src/commands/cmd.scoreboard.cpp
src/commands/cmd.globalstats.h
src/commands/cmd.globalstats.cpp
# csgo api
src/csgo/CSGOClient.h
src/csgo/CSGOClient.cpp
src/csgo/GCMsgHandler.h
src/csgo/CSGOMMHello.h
src/csgo/CSGOMMHello.cpp
src/csgo/CSGOMatchList.h
src/csgo/CSGOMatchList.cpp
src/csgo/CSGOMatchData.h
src/csgo/CSGOMatchPlayerScore.h
src/csgo/CSGOMatchPlayerScore.cpp
src/csgo/CSGORankUpdate.cpp
src/csgo/CSGORankUpdate.h
# csgostats
src/csgostats/ShareCodeUpload.h
src/csgostats/ShareCodeUpload.cpp
src/csgostats/ShareCodeCache.h
src/csgostats/ShareCodeCache.cpp
# windows platform
src/platform/windows/WinCliColors.h
src/platform/windows/WinCliColors.cpp
# Generated Protobuf Includes
${PROTO_ENGINE_GCMESSAGES_SRC}
${PROTO_ENGINE_GCMESSAGES_HDR}
${PROTO_CSTRIKE15_GCMESSAGES_SRC}
${PROTO_CSTRIKE15_GCMESSAGES_HDR}
${PROTO_STEAMMESSAGES_SRC}
${PROTO_STEAMMESSAGES_HDR}
${PROTO_GCSDK_GCMESSAGES_SRC}
${PROTO_GCSDK_GCMESSAGES_HDR}
${PROTO_GCSYSTEMMSGS_SRC}
${PROTO_GCSYSTEMMSGS_HDR}
)
# Ensure that any targets that depend on the patched protobufs are built after the patching is done
add_dependencies(csgo_cli_lib patch_steamdatabase_csgo_protobufs)
#
# Process CS:GO Protobufs
# See comment above @ "protobuf_MODULE_COMPATIBLE"
#
#protobuf_generate(
# LANGUAGE cpp
# TARGET csgo_cli_lib
# PROTOS
# ${SteamDatabase_Protobufs_SOURCE_DIR}/csgo/steammessages.proto
# ${SteamDatabase_Protobufs_SOURCE_DIR}/csgo/gcsdk_gcmessages.proto
# ${SteamDatabase_Protobufs_SOURCE_DIR}/csgo/gcsystemmsgs.proto
# ${SteamDatabase_Protobufs_SOURCE_DIR}/csgo/engine_gcmessages.proto
# ${SteamDatabase_Protobufs_SOURCE_DIR}/csgo/cstrike15_gcmessages.proto
#)
target_include_directories(csgo_cli_lib
PUBLIC
${STEAMWORKS_INCLUDE_DIR}
${PROTOBUF_INCLUDE_DIR}
${CURL_INCLUDE_DIR}
${fmt_INCLUDE_DIRS}
)
target_link_libraries(csgo_cli_lib
PRIVATE
fmt::fmt
#spdlog::spdlog
nlohmann_json::nlohmann_json
CURL::libcurl
ZLIB::ZLIB
${STEAMWORKS_LIBRARY}
protobuf::libprotobuf
)
set_property(TARGET csgo_cli_lib PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
target_compile_features(csgo_cli_lib PUBLIC cxx_std_20)
if(MSVC)
if(ENABLE_ASAN)
target_compile_options(csgo_cli_lib PUBLIC -fsanitize=address)
endif()
endif()
target_link_options(csgo_cli_lib
PRIVATE
$<$<CONFIG:Debug>: /NODEFAULTLIB:LIBCMTD;>
#$<$<CONFIG:Release>: /NODEFAULTLIB:LIBCMT;>
)
#-------------------------------------------------------------------
# Build Target: csgo_cli (app)
#-------------------------------------------------------------------
add_executable(csgo_cli
# icon
${ADDITIONAL_RESOURCES}
# application files
src/main/main.cpp
)
target_include_directories(csgo_cli
PUBLIC
${STEAMWORKS_INCLUDE_DIR}
)
target_link_libraries(csgo_cli
PRIVATE
csgo_cli_lib
fmt::fmt-header-only
)
set_property(TARGET csgo_cli PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
target_compile_features(csgo_cli PUBLIC cxx_std_20)
if(MSVC)
if(ENABLE_ASAN)
target_compile_options(csgo_cli PUBLIC -fsanitize=address)
endif()
endif()
#
# Create "source-group" folders for these files in Visual Studio
#
# source_group("CSGO Protobuf Protocol Files" FILES
# proto/engine_gcmessages.proto
# proto/cstrike15_gcmessages.proto
# proto/steammessages.proto
# proto/gcsdk_gcmessages.proto
# proto/gcsystemmsgs.proto
# )
#-------------------------------------------------------------------
# Tests
#-------------------------------------------------------------------
if(BUILD_TESTS)
add_subdirectory(tests)
endif()
#-------------------------------------------------------------------
# Installation Rules: csgo_cli (app)
#-------------------------------------------------------------------
include(GNUInstallDirs)
install(TARGETS csgo_cli RESOURCE)
install(FILES "${CMAKE_BINARY_DIR}/readme.txt" DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES "${CMAKE_BINARY_DIR}/license.txt" DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES "${CMAKE_BINARY_DIR}/update.bat" DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES "${CMAKE_BINARY_DIR}/curl-ca-bundle.crt" DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES "${CMAKE_BINARY_DIR}/steam_appid.txt" DESTINATION ${CMAKE_INSTALL_BINDIR})
if(WIN32)
install(FILES "${CMAKE_BINARY_DIR}/steam_api64.dll" DESTINATION ${CMAKE_INSTALL_BINDIR})
else()
install(FILES "${CMAKE_BINARY_DIR}/libsteam_api.so" DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
#-------------------------------------------------------------------
# Display Compiler and Linker properties of Build Targets
#-------------------------------------------------------------------
show_build_target_properties(csgo_cli_lib)
show_build_target_properties(csgo_cli)