forked from Nemirtingas/ingame_overlay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
560 lines (476 loc) · 14.6 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
cmake_policy(SET CMP0091 NEW)
project(ingame_overlay)
cmake_minimum_required(VERSION 3.15)
if(WIN32) # Setup some variables for Windows build
set(INGAMEOVERLAY_SOURCES
src/Base_Hook.cpp
src/windows/Renderer_Detector.cpp
src/windows/DX9_Hook.cpp
src/windows/DX10_Hook.cpp
src/windows/DX11_Hook.cpp
src/windows/DX12_Hook.cpp
src/windows/OpenGL_Hook.cpp
src/windows/Vulkan_Hook.cpp
src/windows/Windows_Hook.cpp
)
set(PRIVATE_INGAMEOVERLAY_HEADERS
src/Base_Hook.h
src/windows/DX9_Hook.h
src/windows/DX10_Hook.h
src/windows/DX11_Hook.h
src/windows/DX12_Hook.h
src/windows/OpenGL_Hook.h
src/windows/Vulkan_Hook.h
src/windows/Windows_Hook.h
)
set(IMGUI_SOURCES
deps/ImGui/imgui.cpp
deps/ImGui/imgui_draw.cpp
deps/ImGui/imgui_tables.cpp
deps/ImGui/imgui_widgets.cpp
deps/ImGui/backends/imgui_impl_dx9.cpp
deps/ImGui/backends/imgui_impl_dx10.cpp
deps/ImGui/backends/imgui_impl_dx11.cpp
deps/ImGui/backends/imgui_impl_dx12.cpp
deps/ImGui/backends/imgui_impl_opengl3.cpp
deps/ImGui/backends/imgui_impl_vulkan.cpp
deps/ImGui/backends/imgui_impl_win32.cpp
deps/ImGui/backends/imgui_win_shader_blobs.cpp
)
elseif(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
set(CMAKE_OBJCXX_FLAGS "${CMAKE_OBJCXX_FLAGS} -stdlib=libc++")
enable_language(OBJCXX)
link_libraries("-framework AppKit -framework Carbon -framework Metal -framework MetalKit")
set(INGAMEOVERLAY_SOURCES
src/Base_Hook.cpp
src/macosx/Renderer_Detector.mm
src/macosx/NSView_Hook.mm
src/macosx/OpenGL_Hook.mm
src/macosx/Metal_Hook.mm
)
set(PRIVATE_INGAMEOVERLAY_HEADERS
src/Base_Hook.h
src/macosx/NSView_Hook.h
src/macosx/OpenGL_Hook.h
src/macosx/Metal_Hook.h
)
set(IMGUI_SOURCES
deps/ImGui/imgui.cpp
deps/ImGui/imgui_draw.cpp
deps/ImGui/imgui_tables.cpp
deps/ImGui/imgui_widgets.cpp
deps/ImGui/backends/imgui_impl_opengl2.cpp
deps/ImGui/backends/imgui_impl_metal.mm
deps/ImGui/backends/imgui_impl_osx.mm
)
elseif(UNIX)
set(INGAMEOVERLAY_SOURCES
src/Base_Hook.cpp
src/linux/Renderer_Detector.cpp
src/linux/OpenGLX_Hook.cpp
src/linux/X11_Hook.cpp
)
set(PRIVATE_INGAMEOVERLAY_HEADERS
src/Base_Hook.h
src/linux/OpenGLX_Hook.h
src/linux/X11_Hook.h
)
set(IMGUI_SOURCES
deps/ImGui/imgui.cpp
deps/ImGui/imgui_draw.cpp
deps/ImGui/imgui_tables.cpp
deps/ImGui/imgui_widgets.cpp
deps/ImGui/backends/imgui_impl_vulkan.cpp
deps/ImGui/backends/imgui_impl_opengl3.cpp
deps/ImGui/backends/imgui_impl_x11.cpp
)
else()
message(FATAL_ERROR "No CMake for other platforms")
endif()
set(CMAKE_C_STANDARD_LIBRARIES "" CACHE STRING "" FORCE)
set(CMAKE_CXX_STANDARD_LIBRARIES "" CACHE STRING "" FORCE)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
option(BUILD_INGAMEOVERLAY_TESTS "Build tests." OFF)
option(USE_SPDLOG "Enable logs with SPDLOG." OFF)
find_package(Threads REQUIRED)
if(NOT ${IMGUI_USER_CONFIG} STREQUAL "")
set(IMGUI_USER_CONFIG_VALUE IMGUI_USER_CONFIG="${IMGUI_USER_CONFIG}")
get_filename_component(IMGUI_USER_CONFIG_NAME_VALUE ${IMGUI_USER_CONFIG} NAME)
set(IMGUI_USER_CONFIG_NAME_VALUE IMGUI_USER_CONFIG="${IMGUI_USER_CONFIG_NAME_VALUE}")
else()
set(IMGUI_USER_CONFIG "" CACHE FILEPATH "")
endif()
set(INGAMEOVERLAY_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/include/ingame_overlay/Renderer_Hook.h
${CMAKE_CURRENT_SOURCE_DIR}/include/ingame_overlay/Renderer_Detector.h
)
set(INGAMEOVERLAY_IMGUI_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/deps/ImGui/imconfig.h
${CMAKE_CURRENT_SOURCE_DIR}/deps/ImGui/imgui.h
${CMAKE_CURRENT_SOURCE_DIR}/deps/ImGui/imgui_internal.h
${CMAKE_CURRENT_SOURCE_DIR}/deps/ImGui/imstb_rectpack.h
${CMAKE_CURRENT_SOURCE_DIR}/deps/ImGui/imstb_textedit.h
${CMAKE_CURRENT_SOURCE_DIR}/deps/ImGui/imstb_truetype.h
$<$<BOOL:${IMGUI_USER_CONFIG}>:${IMGUI_USER_CONFIG}>
)
add_subdirectory(deps/System EXCLUDE_FROM_ALL)
add_subdirectory(deps/mini_detour EXCLUDE_FROM_ALL)
add_library(ingame_overlay
${INGAMEOVERLAY_SOURCES}
${IMGUI_SOURCES}
${INGAMEOVERLAY_HEADERS}
${PRIVATE_INGAMEOVERLAY_HEADERS}
)
set_target_properties(ingame_overlay PROPERTIES
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>"
POSITION_INDEPENDENT_CODE ON
C_VISIBILITY_PRESET hidden
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON
)
target_link_libraries(ingame_overlay
PUBLIC
System::System
MiniDetour::MiniDetour
$<$<BOOL:${USE_SPDLOG}>:spdlog::spdlog>
$<$<BOOL:${WIN32}>:opengl32>
$<$<BOOL:${UNIX}>:dl>
$<$<AND:$<BOOL:${UNIX}>,$<NOT:$<BOOL:${APPLE}>>>:GL>
$<$<AND:$<BOOL:${UNIX}>,$<NOT:$<BOOL:${APPLE}>>>:X11>
)
target_compile_options(ingame_overlay
PRIVATE
$<$<BOOL:${MSVC}>:/MP>
)
target_include_directories(ingame_overlay
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/deps/ImGui>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/vulkan_sdk/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/glad2/include>
$<INSTALL_INTERFACE:include>
)
target_compile_definitions(ingame_overlay
PRIVATE
IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS
$<$<BOOL:${USE_SPDLOG}>:USE_SPDLOG>
$<BUILD_INTERFACE:${IMGUI_USER_CONFIG_VALUE}>
$<BUILD_INTERFACE:IMGUI_DISABLE_DEMO_WINDOWS>
PUBLIC
$<INSTALL_INTERFACE:${IMGUI_USER_CONFIG_NAME_VALUE}>
IMGUI_IMPL_OPENGL_LOADER_CUSTOM
IMGUI_IMPL_OPENGL_LOADER_GLAD2
IMGUI_IMPL_VULKAN_NO_PROTOTYPES
IMGUI_DISABLE_OBSOLETE_KEYIO
IMGUI_DISABLE_OBSOLETE_FUNCTIONS
IMGUI_DISABLE_APPLE_GAMEPAD
)
add_library(InGameOverlay::InGameOverlay ALIAS ingame_overlay)
set_target_properties(ingame_overlay PROPERTIES EXPORT_NAME InGameOverlay)
if(${BUILD_INGAMEOVERLAY_TESTS})
if(WIN32)
add_executable(dx9_app
tests/dx9/main.cpp
deps/ImGui/imgui.cpp
deps/ImGui/imgui_demo.cpp
deps/ImGui/imgui_draw.cpp
deps/ImGui/imgui_tables.cpp
deps/ImGui/imgui_widgets.cpp
deps/ImGui/backends/imgui_impl_dx9.cpp
deps/ImGui/backends/imgui_impl_win32.cpp
deps/ImGui/backends/imgui_win_shader_blobs.cpp
)
target_include_directories(dx9_app
PRIVATE
deps/ImGui
)
target_link_libraries(dx9_app
PRIVATE
user32
d3d9
)
target_compile_definitions(dx9_app
PRIVATE
${IMGUI_USER_CONFIG_VALUE}
IMGUI_IMPL_OPENGL_LOADER_CUSTOM
IMGUI_IMPL_OPENGL_LOADER_GLAD2
IMGUI_IMPL_VULKAN_NO_PROTOTYPES
IMGUI_DISABLE_OBSOLETE_KEYIO
IMGUI_DISABLE_OBSOLETE_FUNCTIONS
IMGUI_DISABLE_APPLE_GAMEPAD
)
set_property(TARGET dx9_app PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
add_executable(dx10_app
tests/dx10/main.cpp
deps/ImGui/imgui.cpp
deps/ImGui/imgui_demo.cpp
deps/ImGui/imgui_draw.cpp
deps/ImGui/imgui_tables.cpp
deps/ImGui/imgui_widgets.cpp
deps/ImGui/backends/imgui_impl_dx10.cpp
deps/ImGui/backends/imgui_impl_win32.cpp
deps/ImGui/backends/imgui_win_shader_blobs.cpp
)
target_include_directories(dx10_app
PRIVATE
deps/ImGui
)
target_link_libraries(dx10_app
PRIVATE
user32
d3d10
)
target_compile_definitions(dx10_app
PRIVATE
${IMGUI_USER_CONFIG_VALUE}
IMGUI_IMPL_OPENGL_LOADER_CUSTOM
IMGUI_IMPL_OPENGL_LOADER_GLAD2
IMGUI_IMPL_VULKAN_NO_PROTOTYPES
IMGUI_DISABLE_OBSOLETE_KEYIO
IMGUI_DISABLE_OBSOLETE_FUNCTIONS
IMGUI_DISABLE_APPLE_GAMEPAD
)
set_property(TARGET dx10_app PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
add_executable(dx11_app
tests/dx11/main.cpp
deps/ImGui/imgui.cpp
deps/ImGui/imgui_demo.cpp
deps/ImGui/imgui_draw.cpp
deps/ImGui/imgui_tables.cpp
deps/ImGui/imgui_widgets.cpp
deps/ImGui/backends/imgui_impl_dx11.cpp
deps/ImGui/backends/imgui_impl_win32.cpp
deps/ImGui/backends/imgui_win_shader_blobs.cpp
)
target_include_directories(dx11_app
PRIVATE
deps/ImGui
)
target_link_libraries(dx11_app
PRIVATE
user32
d3d11
)
target_compile_definitions(dx11_app
PRIVATE
${IMGUI_USER_CONFIG_VALUE}
IMGUI_IMPL_OPENGL_LOADER_CUSTOM
IMGUI_IMPL_OPENGL_LOADER_GLAD2
IMGUI_IMPL_VULKAN_NO_PROTOTYPES
IMGUI_DISABLE_OBSOLETE_KEYIO
IMGUI_DISABLE_OBSOLETE_FUNCTIONS
IMGUI_DISABLE_APPLE_GAMEPAD
)
set_property(TARGET dx11_app PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
add_executable(dx12_app
tests/dx12/main.cpp
deps/ImGui/imgui.cpp
deps/ImGui/imgui_demo.cpp
deps/ImGui/imgui_draw.cpp
deps/ImGui/imgui_tables.cpp
deps/ImGui/imgui_widgets.cpp
deps/ImGui/backends/imgui_impl_dx12.cpp
deps/ImGui/backends/imgui_impl_win32.cpp
deps/ImGui/backends/imgui_win_shader_blobs.cpp
)
target_include_directories(dx12_app
PRIVATE
deps/ImGui
)
target_link_libraries(dx12_app
PRIVATE
user32
d3d12
dxgi
)
target_compile_definitions(dx12_app
PRIVATE
${IMGUI_USER_CONFIG_VALUE}
IMGUI_IMPL_OPENGL_LOADER_CUSTOM
IMGUI_IMPL_OPENGL_LOADER_GLAD2
IMGUI_IMPL_VULKAN_NO_PROTOTYPES
IMGUI_DISABLE_OBSOLETE_KEYIO
IMGUI_DISABLE_OBSOLETE_FUNCTIONS
IMGUI_DISABLE_APPLE_GAMEPAD
)
set_property(TARGET dx12_app PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
add_executable(windows_opengl3_app
tests/windows_opengl3/main.cpp
deps/ImGui/imgui.cpp
deps/ImGui/imgui_demo.cpp
deps/ImGui/imgui_draw.cpp
deps/ImGui/imgui_tables.cpp
deps/ImGui/imgui_widgets.cpp
deps/ImGui/backends/imgui_impl_opengl3.cpp
deps/ImGui/backends/imgui_impl_win32.cpp
)
target_include_directories(windows_opengl3_app
PRIVATE
deps/ImGui
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/glad2/include>
)
target_link_libraries(windows_opengl3_app
PRIVATE
user32
opengl32
)
target_compile_definitions(windows_opengl3_app
PRIVATE
${IMGUI_USER_CONFIG_VALUE}
IMGUI_IMPL_OPENGL_LOADER_CUSTOM
IMGUI_IMPL_OPENGL_LOADER_GLAD2
IMGUI_IMPL_VULKAN_NO_PROTOTYPES
IMGUI_DISABLE_OBSOLETE_KEYIO
IMGUI_DISABLE_OBSOLETE_FUNCTIONS
IMGUI_DISABLE_APPLE_GAMEPAD
)
set_property(TARGET windows_opengl3_app PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
elseif(APPLE)
add_executable(macos_opengl2_app
tests/macos_opengl2/main.mm
deps/ImGui/imgui.cpp
deps/ImGui/imgui_demo.cpp
deps/ImGui/imgui_draw.cpp
deps/ImGui/imgui_tables.cpp
deps/ImGui/imgui_widgets.cpp
deps/ImGui/backends/imgui_impl_opengl2.cpp
deps/ImGui/backends/imgui_impl_osx.mm
)
target_include_directories(macos_opengl2_app
PRIVATE
deps/ImGui
${CMAKE_CURRENT_SOURCE_DIR}/src/glad2/include
)
target_link_libraries(macos_opengl2_app
PRIVATE
dl
)
target_compile_definitions(macos_opengl2_app
PRIVATE
${IMGUI_USER_CONFIG_VALUE}
IMGUI_IMPL_OPENGL_LOADER_CUSTOM
IMGUI_IMPL_OPENGL_LOADER_GLAD2
IMGUI_IMPL_VULKAN_NO_PROTOTYPES
IMGUI_DISABLE_OBSOLETE_KEYIO
IMGUI_DISABLE_OBSOLETE_FUNCTIONS
IMGUI_DISABLE_APPLE_GAMEPAD
)
add_executable(macos_metal_app
tests/macos_metal/main.mm
deps/ImGui/imgui.cpp
deps/ImGui/imgui_demo.cpp
deps/ImGui/imgui_draw.cpp
deps/ImGui/imgui_tables.cpp
deps/ImGui/imgui_widgets.cpp
deps/ImGui/backends/imgui_impl_metal.mm
deps/ImGui/backends/imgui_impl_osx.mm
)
target_include_directories(macos_metal_app
PRIVATE
deps/ImGui
${CMAKE_CURRENT_SOURCE_DIR}/src/glad2/include
)
set_target_properties(macos_metal_app PROPERTIES
BUNDLE True
MACOSX_BUNDLE_GUI_IDENTIFIER my.domain.style.identifier.macos_metal_app
MACOSX_BUNDLE_BUNDLE_NAME macos_metal_app
MACOSX_BUNDLE_BUNDLE_VERSION "1"
MACOSX_BUNDLE_SHORT_VERSION_STRING "1"
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/cmake/customtemplate.plist.in
)
target_link_libraries(macos_metal_app
PRIVATE
dl
)
target_compile_definitions(macos_metal_app
PRIVATE
${IMGUI_USER_CONFIG_VALUE}
IMGUI_IMPL_OPENGL_LOADER_CUSTOM
IMGUI_IMPL_OPENGL_LOADER_GLAD2
IMGUI_IMPL_VULKAN_NO_PROTOTYPES
IMGUI_DISABLE_OBSOLETE_KEYIO
IMGUI_DISABLE_OBSOLETE_FUNCTIONS
IMGUI_DISABLE_APPLE_GAMEPAD
)
elseif(UNIX)
add_executable(linux_opengl_app
tests/linux_opengl/main.cpp
deps/ImGui/imgui.cpp
deps/ImGui/imgui_demo.cpp
deps/ImGui/imgui_draw.cpp
deps/ImGui/imgui_tables.cpp
deps/ImGui/imgui_widgets.cpp
deps/ImGui/backends/imgui_impl_opengl3.cpp
deps/ImGui/backends/imgui_impl_x11.cpp
)
target_include_directories(linux_opengl_app
PRIVATE
deps/ImGui
${CMAKE_CURRENT_SOURCE_DIR}/src/glad2/include
)
target_link_libraries(linux_opengl_app
PRIVATE
dl
GL
X11
)
target_compile_definitions(linux_opengl_app
PRIVATE
${IMGUI_USER_CONFIG_VALUE}
IMGUI_IMPL_OPENGL_LOADER_CUSTOM
IMGUI_IMPL_OPENGL_LOADER_GLAD2
IMGUI_IMPL_VULKAN_NO_PROTOTYPES
IMGUI_DISABLE_OBSOLETE_KEYIO
IMGUI_DISABLE_OBSOLETE_FUNCTIONS
IMGUI_DISABLE_APPLE_GAMEPAD
)
endif()
add_library(overlay_example SHARED
tests/overlay_example/library_main.cpp
)
set_target_properties(overlay_example PROPERTIES
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>"
POSITION_INDEPENDENT_CODE ON
C_VISIBILITY_PRESET hidden
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON
)
target_link_options(overlay_example
PRIVATE
$<$<AND:$<NOT:$<BOOL:${APPLE}>>,$<BOOL:${UNIX}>>:-Wl,--exclude-libs,ALL>
$<$<AND:$<NOT:$<BOOL:${APPLE}>>,$<BOOL:${UNIX}>>:-Wl,--no-undefined>
)
target_link_libraries(overlay_example
PRIVATE
InGameOverlay::InGameOverlay
Threads::Threads
)
endif()
##################
## Install rules
install(TARGETS ingame_overlay EXPORT InGameOverlayTargets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
install(FILES ${INGAMEOVERLAY_HEADERS}
DESTINATION include/ingame_overlay
)
install(FILES ${INGAMEOVERLAY_IMGUI_HEADERS}
DESTINATION include/ingame_overlay/ImGui
)
# Export targets
install(
EXPORT InGameOverlayTargets
FILE InGameOverlayConfig.cmake
NAMESPACE InGameOverlay::
DESTINATION lib/cmake/InGameOverlay
)