-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
221 lines (204 loc) · 9.04 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
cmake_minimum_required(VERSION 3.21)
# Set the Project Name.
set(PROJECT_NAME EnigmaFix)
# Set the name of the target operating system.
set(CMAKE_SYSTEM_NAME Windows)
if (UNIX) # If compiling on Linux, manually configure MingW-64.
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
# Set the Toolchain to MinGW on Linux.
set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32)
link_directories(${CMAKE_FIND_ROOT_PATH}/sys-root/mingw/lib) # TODO: Fix to also work with MinGW on Windows.
# adjust the default behavior of the FIND_XXX() commands:
# Never search for programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# Search for headers and libraries only in the target environment
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
# Add Boost Include Directory (For MinGW).
#set(Boost_INCLUDE_DIR ${CMAKE_FIND_ROOT_PATH}/sys-root/mingw/include/)
endif (UNIX)
# Set our output directories
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Binaries/${CMAKE_SYSTEM_NAME})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Binaries/${CMAKE_SYSTEM_NAME})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Binaries/${CMAKE_SYSTEM_NAME})
# Set our intermediate directories.
set(CMAKE_BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Intermediate/${CMAKE_BUILD_TYPE})
set(CMAKE_BUILD_FILES_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Intermediate/${CMAKE_BUILD_TYPE})
# Set our compile method to Ninja.
set(CMAKE_GENERATOR Ninja)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_C_STANDARD 23)
# Set a definition for a debug build through CMake. Also includes GDB debugging information.
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -DDEBUG -ggdb3")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -DDEBUG -ggdb3")
# Set compile flags for release builds, this should strip the debug symbols and optimizes it.
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2 -s")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -s")
## Setup Boost (Still need to sort out the error regarding "the target platform not supporting dynamic linking"
#find_package(Boost REQUIRED COMPONENTS) # Add Boost Components Here.
# Include Boost directories
#include_directories(${Boost_INCLUDE_DIRS})
# Set up our ThirdParty libraries
include(FetchContent)
## SafetyHook (With Zydis)
option(SAFETYHOOK_FETCH_ZYDIS "Option to fetch Zydis" ON)
### Pass the option to the compiler
if(SAFETYHOOK_FETCH_ZYDIS)
add_definitions(-DSAFETYHOOK_FETCH_ZYDIS)
endif()
set(SAFETYHOOK_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/Source/ThirdParty/SafetyHook")
message(STATUS "Fetching SafetyHook...")
FetchContent_Declare(
SafetyHook
GIT_REPOSITORY "https://github.com/cursey/safetyhook.git"
GIT_TAG "origin/main"
SOURCE_DIR "${SAFETYHOOK_SOURCE_DIR}"
)
FetchContent_MakeAvailable(SafetyHook)
## SpdLog
set(SPDLOG_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/Source/ThirdParty/SpdLog")
message(STATUS "Fetching SpdLog...")
FetchContent_Declare(
SpdLog
GIT_REPOSITORY "https://github.com/gabime/spdlog.git"
GIT_TAG "origin/v1.x"
SOURCE_DIR "${SPDLOG_SOURCE_DIR}"
)
FetchContent_MakeAvailable(SpdLog)
## ImGui
set(IMGUI_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/Source/ThirdParty/ImGui")
message(STATUS "Fetching ImGui...")
FetchContent_Declare(
ImGui
GIT_REPOSITORY "https://github.com/ocornut/imgui.git"
GIT_TAG "origin/master"
SOURCE_DIR "${IMGUI_SOURCE_DIR}"
)
FetchContent_MakeAvailable(ImGui)
add_library(imgui STATIC
${IMGUI_SOURCE_DIR}/imgui.cpp
${IMGUI_SOURCE_DIR}/imgui.h
${IMGUI_SOURCE_DIR}/imgui_demo.cpp
${IMGUI_SOURCE_DIR}/imgui_draw.cpp
${IMGUI_SOURCE_DIR}/imgui_tables.cpp
${IMGUI_SOURCE_DIR}/imgui_widgets.cpp
)
add_library(imguibackends STATIC
${IMGUI_SOURCE_DIR}/backends/imgui_impl_dx11.cpp
${IMGUI_SOURCE_DIR}/backends/imgui_impl_dx11.h
${IMGUI_SOURCE_DIR}/backends/imgui_impl_win32.cpp
${IMGUI_SOURCE_DIR}/backends/imgui_impl_win32.h
)
### Include the ImGui header files with the ImGuiBackends, as we don't want to manually modify the includes to add a "../".
target_include_directories(imguibackends PUBLIC ${IMGUI_SOURCE_DIR})
target_link_libraries(imguibackends d3dcompiler dwmapi)
### We then finally link together ImGui and ImGuiBackends, so they're dependent on each other.
target_link_libraries(imgui imguibackends)
## Kiero
set(KIERO_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/Source/ThirdParty/Kiero")
message(STATUS "Fetching Kiero...")
FetchContent_Declare(
Kiero
GIT_REPOSITORY "https://github.com/KingKrouch/Kiero-EnigmaFix.git"
GIT_TAG "origin/master"
SOURCE_DIR "${KIERO_SOURCE_DIR}"
)
FetchContent_MakeAvailable(Kiero)
add_library(kiero STATIC
${KIERO_SOURCE_DIR}/kiero.cpp
${KIERO_SOURCE_DIR}/kiero.h
)
# NOTE: This is just in case I plan on porting SafetyHook to Kiero, rather than using MinHook.
#target_link_libraries(kiero safetyhook) # Include MinHook with Kiero, so we can just have it use that version instead of it's own.
#target_include_directories(kiero PRIVATE "${SAFETYHOOK_SOURCE_DIR}/include")
## MinHook (We are simply gonna fork the latest version of MinHook with it's own CMakeLists.txt rather than using the one with Kiero).
set(MINHOOK_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/Source/ThirdParty/MinHook")
message(STATUS "Fetching MinHook...")
FetchContent_Declare(
MinHook
GIT_REPOSITORY "https://github.com/TsudaKageyu/minhook.git"
GIT_TAG "origin/master"
SOURCE_DIR "${MINHOOK_SOURCE_DIR}"
)
FetchContent_MakeAvailable(MinHook)
target_link_libraries(kiero minhook) # Include MinHook with Kiero, so we can just have it use that version instead of it's own.
target_include_directories(kiero PRIVATE "${MINHOOK_SOURCE_DIR}/include")
## IniPP
set(INIPP_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/Source/ThirdParty/IniPP")
message(STATUS "Fetching IniPP...")
FetchContent_Declare(
IniPP
GIT_REPOSITORY "https://github.com/mcmtroffaes/inipp.git"
GIT_TAG "origin/develop"
SOURCE_DIR "${INIPP_SOURCE_DIR}"
)
FetchContent_MakeAvailable(IniPP)
## JSON
set(JSON_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/Source/ThirdParty/JSON")
message(STATUS "Fetching JSON...")
FetchContent_Declare(
JSON
GIT_REPOSITORY "https://github.com/nlohmann/json.git"
GIT_TAG "origin/develop"
SOURCE_DIR "${JSON_SOURCE_DIR}"
)
FetchContent_MakeAvailable(JSON)
## STB
set(STB_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/Source/ThirdParty/STB")
message(STATUS "Fetching STB...")
FetchContent_Declare(
STB
GIT_REPOSITORY "https://github.com/nothings/stb.git"
GIT_TAG "origin/master"
SOURCE_DIR "${STB_SOURCE_DIR}"
)
FetchContent_MakeAvailable(STB)
add_library(stb STATIC
${STB_SOURCE_DIR}/stb_image.h
)
set_target_properties(stb PROPERTIES LINKER_LANGUAGE CXX)
# Now finally export our library file.
## Setup the project and set a few variables
project(EnigmaFix)
add_library(EnigmaFix SHARED
Source/dllmain.cpp
Source/Localization/Localization.cpp
Source/Localization/Localization.h
Source/Managers/ConfigManager.cpp
Source/Managers/ConfigManager.h
Source/Managers/FramerateManager.cpp
Source/Managers/FramerateManager.h
Source/Managers/HookManager.cpp
Source/Managers/HookManager.h
Source/Managers/PatchManager.cpp
Source/Managers/PatchManager.h
Source/Managers/PluginManager.cpp
Source/Managers/PluginManager.h
Source/Managers/RenderManager.cpp
Source/Managers/RenderManager.h
Source/Managers/UIManager.cpp
Source/Managers/UIManager.h
Source/Settings/PlayerSettings.cpp
Source/Settings/PlayerSettings.h
Source/Plugins/Plugin_DERQ.cpp
Source/Plugins/Plugin_DERQ.h
Source/Utilities/UITextureLoader.cpp
Source/Utilities/UITextureLoader.h
Source/Utilities/DXHelper.h
Source/Utilities/DXEnums.h
)
## Add the dependencies we set up previously.
# NOTE: Add "" to the "add_dependencies" section when you finally get that shit working.
add_dependencies(EnigmaFix imgui kiero safetyhook inipp nlohmann_json spdlog stb)
target_link_libraries(EnigmaFix PRIVATE d3dcompiler imgui kiero safetyhook inipp nlohmann_json spdlog stb)
#target_link_libraries(EnigmaFix d3dcompiler imgui kiero inipp ${Boost_LIBRARIES})
## Set up our linker flags for compiling.
set(CMAKE_SHARED_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static -municode -Wl,--file-alignment=4096")
# Renames our output to an ASI extension for use with Ultimate ASI Loader.
set_target_properties(EnigmaFix PROPERTIES PREFIX "" OUTPUT_NAME EnigmaFix SUFFIX ".asi")
## Now we delete any miscellaneous .a static library files for release builds, as we don't need them.
if(CMAKE_BUILD_TYPE STREQUAL "Release")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E remove $<TARGET_FILE_DIR:${PROJECT_NAME}>/*.a)
endif()