-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
CMakeLists.txt
144 lines (107 loc) · 4.69 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
cmake_minimum_required(VERSION 3.24.0)
project(Flarial VERSION 1.0 LANGUAGES CXX)
include(FetchContent)
set(CMAKE_CXX_STANDARD 23)
execute_process(
COMMAND git rev-parse --short HEAD
OUTPUT_VARIABLE COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/commit_hash.h.in
${CMAKE_CURRENT_BINARY_DIR}/commit_hash.h
@ONLY
)
add_definitions(-DCOMMIT_HASH="${COMMIT_HASH}")
if(MSVC)
add_compile_options(/MT)
add_compile_options(/bigobj)
# Needed for fmt library
add_compile_options(/utf-8)
# 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 "src/**/*.cpp" "src/**/*.hpp" "lib/**/*.cpp" "src/Client/GUI/Engine/*.cpp")
add_library(${PROJECT_NAME} SHARED ${sources} main.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")
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/lib/freetype/")
add_library(FreeType SHARED IMPORTED GLOBAL)
set_target_properties(FreeType PROPERTIES IMPORTED_IMPLIB "${CMAKE_CURRENT_SOURCE_DIR}/lib/freetype/libs/freetype.lib")
FetchContent_Declare(
entt
GIT_REPOSITORY https://github.com/skypjack/entt.git
GIT_TAG f931687ff04d435871ac9664bb299f71f2a8fafc
)
FetchContent_Declare(
nes
GIT_REPOSITORY https://github.com/DisabledMallis/NuvolaEventSystem.git
GIT_TAG main
)
FetchContent_Declare(
libhat
GIT_REPOSITORY https://github.com/BasedInc/libhat.git
GIT_TAG 9ef05d6961ce37a4c801f11159de895aa21878a9
)
FetchContent_Declare(
fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt
GIT_TAG master
)
set(ENTT_BUILD_TESTING OFF) # Disable building tests
FetchContent_MakeAvailable(libhat entt nes fmt)
target_link_libraries(${PROJECT_NAME} PRIVATE libhat fmt::fmt EnTT::EnTT NES windowscodecs.lib urlmon.lib dwrite.lib d3d12.lib dxgi.lib d3d11.lib d2d1.lib wininet.lib version FreeType)
target_link_libraries(${PROJECT_NAME} PUBLIC MinHook)
target_precompile_headers(Flarial PRIVATE "src/PCH.cpp")