-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
138 lines (115 loc) · 4.29 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
cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
if(POLICY CMP0092)
cmake_policy(SET CMP0092 NEW) # Don't add -W3 warning level by default.
endif()
if(POLICY CMP0091)
cmake_policy(SET CMP0091 NEW)
endif()
project(cs2-sdk-plugin VERSION 1.0.0.0 DESCRIPTION "CS2 SDK Plugin" HOMEPAGE_URL "https://github.com/untrustedmodders/cs2-sdk-plugin" LANGUAGES C CXX ASM)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if(UNIX AND NOT APPLE)
set(LINUX TRUE)
endif()
if(WIN32 AND NOT MSVC)
message(FATAL "MSVC restricted.")
endif()
#
# Format
#
include(cmake/compat_format.cmake)
#
# SDK
#
add_subdirectory(external/sourcesdk)
# Sources
file(GLOB_RECURSE SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp")
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/external/dynlibutils/module.cpp)
set(SOURCESDK_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/sourcesdk)
set(METAMOD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/metamod-source)
target_include_directories(${PROJECT_NAME} PRIVATE
${SOURCESDK_DIR}
${SOURCESDK_DIR}/thirdparty/protobuf/src
${SOURCESDK_DIR}/common
${SOURCESDK_DIR}/game/shared
${SOURCESDK_DIR}/game/server
${SOURCESDK_DIR}/public
${SOURCESDK_DIR}/public/engine
${SOURCESDK_DIR}/public/mathlib
${SOURCESDK_DIR}/public/tier0
${SOURCESDK_DIR}/public/tier1
${SOURCESDK_DIR}/public/entity2
${SOURCESDK_DIR}/public/game/server
${SOURCESDK_DIR}/public/entity2
${METAMOD_DIR}/core
${METAMOD_DIR}/core/sourcehook
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/src/core/cs2_sdk
${CMAKE_CURRENT_SOURCE_DIR}/external/dynlibutils
)
target_precompile_headers(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/pch.h)
include(GenerateExportHeader)
generate_export_header(${PROJECT_NAME} EXPORT_MACRO_NAME PLUGIN_API EXPORT_FILE_NAME ${CMAKE_BINARY_DIR}/exports/plugin_export.h)
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_BINARY_DIR}/exports)
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "cs2sdk")
target_compile_definitions(${PROJECT_NAME} PRIVATE
CS2SDK_LOGGING_PREFIX="cs2-sdk"
CS2SDK_PLATFORM_WINDOWS=$<BOOL:${WIN32}>
CS2SDK_PLATFORM_APPLE=$<BOOL:${APPLE}>
CS2SDK_PLATFORM_LINUX=$<BOOL:${LINUX}>
CS2SDK_LIBRARY_SUFFIX="${CMAKE_SHARED_LIBRARY_SUFFIX}"
CS2SDK_LIBRARY_PREFIX="${CMAKE_SHARED_LIBRARY_PREFIX}"
CS2SDK_PLATFORM="linux"
CS2SDK_BINARY="linuxsteamrt64"
CS2SDK_ROOT_BINARY="/bin/linuxsteamrt64/"
# Metamod hack
CS2SDK_GAME_BINARY="/bin/linuxsteamrt64/../../csgo/bin/linuxsteamrt64/"
PLUGIFY_FORMAT_SUPPORT=$<BOOL:${COMPILER_SUPPORTS_FORMAT}>
PLUGIFY_IS_DEBUG=$<STREQUAL:${CMAKE_BUILD_TYPE},Debug>
)
if(NOT COMPILER_SUPPORTS_FORMAT)
target_link_libraries(${PROJECT_NAME} PRIVATE fmt::fmt-header-only)
endif()
if(LINUX)
target_compile_definitions(${PROJECT_NAME} PRIVATE
META_IS_SOURCE2
_LINUX
POSIX
LINUX
GNUC
COMPILER_GCC
PLATFORM_64BITS
bswap_16=__bswap_16
bswap_32=__bswap_32
bswap_64=__bswap_64
_GLIBCXX_USE_CXX11_ABI=0
)
target_link_libraries(${PROJECT_NAME} PRIVATE -static-libstdc++ -static-libgcc)
elseif(WIN32)
target_compile_definitions(${PROJECT_NAME} PRIVATE
META_IS_SOURCE2
COMPILER_MSVC
COMPILER_MSVC64
_WIN32
_WINDOWS
_ALLOW_KEYWORD_MACROS
__STDC_LIMIT_MACROS
_CRT_SECURE_NO_WARNINGS=1
_CRT_SECURE_NO_DEPRECATE=1
_CRT_NONSTDC_NO_DEPRECATE=1
)
set_target_properties(${PROJECT_NAME} PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
# Libraries
target_link_libraries(${PROJECT_NAME} PRIVATE sourcesdk)
set(CS2SDK_VERSION "0" CACHE STRING "Set version name")
set(CS2SDK_PACKAGE "cs2sdk" CACHE STRING "Set package name")
configure_file(
${CMAKE_SOURCE_DIR}/cs2sdk.pplugin.in
${CMAKE_BINARY_DIR}/cs2sdk.pplugin
)