-
Notifications
You must be signed in to change notification settings - Fork 14
/
CMakeLists.txt
250 lines (206 loc) · 6.67 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
cmake_minimum_required (VERSION 3.12)
project (game_overlay_sdk)
macro(configure_msvc_runtime)
if(MSVC)
# Default to statically-linked runtime.
if("${MSVC_RUNTIME}" STREQUAL "")
set(MSVC_RUNTIME "static")
endif()
# Set compiler options.
set(variables
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELWITHDEBINFO
)
if(${MSVC_RUNTIME} STREQUAL "static")
message(STATUS
"MSVC -> forcing use of statically-linked runtime."
)
foreach(variable ${variables})
if(${variable} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${variable} "${${variable}}")
endif()
endforeach()
else()
message(STATUS
"MSVC -> forcing use of dynamically-linked runtime."
)
foreach(variable ${variables})
if(${variable} MATCHES "/MT")
string(REGEX REPLACE "/MT" "/MD" ${variable} "${${variable}}")
endif()
endforeach()
endif()
endif()
endmacro()
configure_msvc_runtime ()
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
MESSAGE("64 bits compiler detected")
SET(EX_PLATFORM 64)
SET(EX_PLATFORM_NAME "x64")
SET(GAME_OVERLAY_NAME "GameOverlay64")
SET(INJECTOR_NAME "DLLInjection64")
SET(VULKAN_OVERLAY "VK_LAYER_OCAT_overlay64")
find_library(Vulkan_LIBRARY
NAMES vulkan-1
PATHS
"$ENV{VULKAN_SDK}/Bin"
"$ENV{VULKAN_SDK}/Lib"
)
else(CMAKE_SIZEOF_VOID_P EQUAL 8)
MESSAGE("32 bits compiler detected")
SET(EX_PLATFORM 32)
SET(EX_PLATFORM_NAME "x86")
SET(GAME_OVERLAY_NAME "GameOverlay32")
SET(INJECTOR_NAME "DLLInjection32")
SET(VULKAN_OVERLAY "VK_LAYER_OCAT_overlay32")
find_library(Vulkan_LIBRARY
NAMES vulkan-1
PATHS
"$ENV{VULKAN_SDK}/Bin32"
"$ENV{VULKAN_SDK}/Lib32"
)
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
IF(EX_PLATFORM EQUAL 64)
MESSAGE("Outputting to lib64 and bin64")
SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE
${CMAKE_SOURCE_DIR}/python/game_overlay_sdk/lib
CACHE PATH
"Single Directory for all Libraries"
)
SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE
${CMAKE_SOURCE_DIR}/python/game_overlay_sdk/lib
CACHE PATH
"Single Directory for all Executables."
)
SET (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE
${CMAKE_SOURCE_DIR}/lib/64
CACHE PATH
"Single Directory for all static libraries."
)
ELSE( EX_PLATFORM EQUAL 64 )
SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE
${CMAKE_SOURCE_DIR}/python/game_overlay_sdk/lib
CACHE PATH
"Single Directory for all Libraries"
)
SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE
${CMAKE_SOURCE_DIR}/python/game_overlay_sdk/lib
CACHE PATH
"Single Directory for all Executables."
)
SET (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE
${CMAKE_SOURCE_DIR}/lib/32
CACHE PATH
"Single Directory for all static libraries."
)
ENDIF( EX_PLATFORM EQUAL 64 )
find_path(Vulkan_INCLUDE_DIR
NAMES vulkan/vulkan.h
PATHS
"$ENV{VULKAN_SDK}/Include"
)
################################### NOTE ###############################################
## Injector is compiled without unicode while everything else - with unicode defined! ##
########################################################################################
#---------------- INJECTOR START -----------------#
add_library (
${INJECTOR_NAME} SHARED
src/Utility/Win32Handle.cpp
src/Utility/StringUtils.cpp
src/Utility/SuspendThreads.cpp
src/Utility/FileUtils.cpp
src/DLLInjection/DLLInjection.cpp
src/DLLInjection/Monitor.cpp
src/DLLInjection/MonitorProcessCreation.cpp
)
target_include_directories (${INJECTOR_NAME} PUBLIC
inc
src/Utility
src/DLLInjection/inc
)
#----------------- INJECTOR END -------------------#
#------------------ COMMON START ------------------#
file(GLOB_RECURSE CommonSrc
"src/DLLToInject/Commons/*.cpp"
"src/Utility/*.cpp"
)
add_library (
Commons STATIC
${CommonSrc}
)
target_include_directories (Commons PUBLIC
src
${Vulkan_INCLUDE_DIR}
)
target_compile_definitions(Commons PRIVATE
VK_USE_PLATFORM_WIN32_KHR
_UNICODE
UNICODE
)
target_link_libraries(Commons ${Vulkan_LIBRARY})
#-------------------- COMMON END --------------------#
#-------------------- MINHOOK START -----------------#
file(GLOB_RECURSE MinHookSrc "src/DLLToInject/MinHook/*.c")
add_library(
MinHook STATIC
${MinHookSrc}
)
#-------------------- MINHOOK END -------------------#
#----------------- GameOverlay START ----------------#
file(GLOB_RECURSE GameOverlayD3DSrc "src/DLLToInject/GameOverlay/d3d/*.cpp")
add_library (
${GAME_OVERLAY_NAME} SHARED
${GameOverlayD3DSrc}
src/DLLToInject/GameOverlay/d3d/exports.def
src/DLLToInject/GameOverlay/d3d/res/resource.rc
)
target_link_libraries (${GAME_OVERLAY_NAME} MinHook Commons d3d12 d2d1 dwrite ${Vulkan_LIBRARY} comdlg32 advapi32 odbc32 odbccp32)
target_include_directories ( ${GAME_OVERLAY_NAME} PUBLIC
src
src/DLLToInject/Commons
src/DLLToInject/MinHook/include
src/DLLToInject/LibOVR/include
src/DLLToInject/openvr/headers
src/DLLToInject/GameOverlay/d3d/source
src/DLLToInject/GameOverlay/d3d/deps/d3dx12
)
target_compile_definitions(${GAME_OVERLAY_NAME} PRIVATE
VK_USE_PLATFORM_WIN32_KHR
_UNICODE
UNICODE
)
set_source_files_properties(src/DLLToInject/GameOverlay/d3d/exports.def PROPERTIES HEADER_FILE_ONLY TRUE)
set_target_properties(${GAME_OVERLAY_NAME} PROPERTIES LINK_FLAGS "/DELAYLOAD:d3d12.dll /DEF:\"${CMAKE_SOURCE_DIR}/src/DLLToInject/GameOverlay/d3d/exports.def\"" )
#----------------- GameOverlay END ------------------#
#----------------- VULKAN LAYER START ------------------#
file(GLOB_RECURSE VulkanOverlaySrc "src/DLLToInject/GameOverlay/vulkan/*.cpp")
add_library (
${VULKAN_OVERLAY} SHARED
${VulkanOverlaySrc}
src/DLLToInject/GameOverlay/vulkan/VK_LAYER_OCAT_overlay.def
src/DLLToInject/GameOverlay/vulkan/VK_LAYER_OCAT_overlay.rc
)
target_link_libraries (${VULKAN_OVERLAY} Commons ${GAME_OVERLAY_NAME} d2d1 dwrite comdlg32 advapi32 odbc32 odbccp32)
target_include_directories (${VULKAN_OVERLAY} PUBLIC
src
src/DLLToInject/Commons
${Vulkan_INCLUDE_DIR}
"$ENV{VULKAN_SDK}/Source/layers"
src/DLLToInject/openvr/headers
src/DLLToInject/GameOverlay/d3d/source
src/DLLToInject/LibOVR/include
)
target_compile_definitions(${VULKAN_OVERLAY} PRIVATE
VK_USE_PLATFORM_WIN32_KHR
_CRT_SECURE_NO_WARNINGS
API_NAME="Vulkan"
)
set_source_files_properties(src/DLLToInject/GameOverlay/vulkan/VK_LAYER_OCAT_overlay.def PROPERTIES HEADER_FILE_ONLY TRUE)
set_target_properties(${VULKAN_OVERLAY} PROPERTIES LINK_FLAGS "/DEF:\"${CMAKE_SOURCE_DIR}/src/DLLToInject/GameOverlay/vulkan/VK_LAYER_OCAT_overlay.def\"" )
#----------------- VULKAN LAYER END ------------------#