forked from flarialmc/dll
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
101 lines (73 loc) · 3.51 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
cmake_minimum_required(VERSION 3.24.0)
project(Flarial VERSION 1.0 LANGUAGES CXX)
include(FetchContent)
set(CMAKE_CXX_STANDARD 23)
if(MSVC)
add_compile_options(/MT)
# Optimize for speed
add_compile_options($<$<CONFIG:Release>:/O2>)
add_compile_options($<$<CONFIG:Release>:/Ot>)
add_compile_options($<$<CONFIG:Release>:/Ox>)
add_compile_options($<$<CONFIG:Release>:/Oy>)
# Enable intrinsic functions
add_compile_options($<$<CONFIG:Release>:/Oi>)
# Enable link-time code generation for whole program optimization
add_compile_options($<$<CONFIG:Release>:/GL>)
# Separate functions for the linker to improve the optimization process
add_compile_options($<$<CONFIG:Release>:/Gy>)
# Optimize global data to reduce the binary size
add_compile_options($<$<CONFIG:Release>:/Gw>)
# Enable string pooling to reduce binary size by consolidating duplicate strings
add_compile_options($<$<CONFIG:Release>:/GF>)
# Optimize floating point operations for speed (may introduce minor precision differences)
# add_compile_options($<$<CONFIG:Release>:/fp:fast>)
# Disable RTTI (Run-Time Type Information) to reduce binary size and possibly improve performance
add_compile_options($<$<CONFIG:Release>:/GR->)
# Inline any suitable function to improve performance by reducing function call overhead
add_compile_options($<$<CONFIG:Release>:/Ob2>)
# add_compile_options("$<$<CONFIG:RELEASE>:/Zi>")
# add_link_options("$<$<CONFIG:RELEASE>:/DEBUG>") # Enable debug symbols in release for edge cases.
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded")
endif()
# Default to statically-linked runtime.
if("${MSVC_RUNTIME}" STREQUAL "")
set(MSVC_RUNTIME "static")
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()
file(GLOB_RECURSE sources "main.cpp" "src/**/*.cpp" "src/**/*.hpp" "lib/**/*.cpp")
add_library(${PROJECT_NAME} SHARED ${sources} src/SDK/Client/Render/Matrix.cpp src/Assets/Assets.rc)
target_include_directories(${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_LIST_DIR}/lib/include/" "${CMAKE_CURRENT_LIST_DIR}/lib/glm/" "${CMAKE_CURRENT_LIST_DIR}/lib/ImGui")
# Disable RTTI
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(${PROJECT_NAME} PRIVATE -fno-rtti)
elseif (MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /GR-)
endif()
add_library(MinHook SHARED IMPORTED GLOBAL)
set_target_properties(MinHook PROPERTIES IMPORTED_IMPLIB "${CMAKE_CURRENT_SOURCE_DIR}/lib/minhook/minhook.lib")
FetchContent_Declare(
libhat
GIT_REPOSITORY https://github.com/BasedInc/libhat.git
GIT_TAG 9ef05d6961ce37a4c801f11159de895aa21878a9
)
FetchContent_MakeAvailable(libhat)
target_link_libraries(${PROJECT_NAME} PRIVATE libhat windowscodecs.lib urlmon.lib dwrite.lib d3d12.lib dxgi.lib d3d11.lib d2d1.lib wininet.lib version)
target_link_libraries(${PROJECT_NAME} PUBLIC MinHook)