-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
246 lines (193 loc) · 8.2 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
cmake_minimum_required (VERSION 3.8)
project ("WoWIngameEditor")
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/")
set(EXTERNAL_SOURCE_DIR "${PROJECT_SOURCE_DIR}/external")
include(CheckCXXCompilerFlag)
include("cmake/file_globbing.cmake")
include("cmake/compiler_flags.cmake")
include(FetchContent)
#Better exception handling for visual studio, particularly for tshe asynchronous stuff
#add_compiler_flag_if_supported(CMAKE_CXX_FLAGS /EHa)
#Multi core building for visual studio
add_compiler_flag_if_supported(CMAKE_CXX_FLAGS /MP)
#Allow Big obj for msvc compilation
add_compiler_flag_if_supported(CMAKE_CXX_FLAGS /bigobj)
add_compiler_flag_if_supported (CMAKE_CXX_FLAGS -fPIC)
add_compiler_flag_if_supported (CMAKE_C_FLAGS -fPIC)
# options
option(ADDITIONAL_OPTIMIZATION_FLAGS "Enable optimizations?" OFF)
if(ADDITIONAL_OPTIMIZATION_FLAGS)
message( STATUS "Enabled additional optimization flags for MSVC")
add_compiler_flag_if_supported (CMAKE_CXX_FLAGS /Ob2) # inline any suitable functions
add_compiler_flag_if_supported (CMAKE_CXX_FLAGS /Oi) # enable intrasic functions
add_compiler_flag_if_supported (CMAKE_CXX_FLAGS /Ot) # favor fast code
add_compiler_flag_if_supported (CMAKE_CXX_FLAGS /GL) # whole program optimization
endif()
option(ENABLE_VALIDATION_LOG_TO_CONSOLE "Log to console?" ON)
if(ENABLE_VALIDATION_LOG_TO_CONSOLE)
message( STATUS "Logging to console")
add_definitions(-DVALIDATION_LOG_TO_CONSOLE)
endif()
option(ENABLE_DEBUG_LOG_IN_RELEASE "Enable debug logs in Release?" OFF)
if(ENABLE_DEBUG_LOG_IN_RELEASE)
message( STATUS "Enabled debug logs in Release")
add_definitions(-DDEBUG_LOG_IN_RELEASE)
endif()
option(ENABLE_CONTRACTS_IN_RELEASE "Enable contract validation in Release?" OFF)
if(ENABLE_CONTRACTS_IN_RELEASE)
message( STATUS "Enabled contract validation in Release")
add_definitions(-DENABLE_CONTRACTS_IN_RELEASE)
endif()
option(BUILD_TESTS "Build tests?" ON)
if(BUILD_TESTS)
message( STATUS "Building tests")
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
set(BUILD_SHARED_LIBS TRUE)
endif()
# logging flags
set(LOGGING_FLAGS_ 0x0)
option(LOGGING_FLAGS_GRAPHICS "Enable graphics loggers?" ON)
if(LOGGING_FLAGS_GRAPHICS)
message( STATUS "Graphics loggers enabled")
math(EXPR LOGGING_FLAGS_ "${LOGGING_FLAGS_} | 0x1")
endif()
option(LOGGING_FLAGS_CLIENT_HOOKS "Enable client hooks loggers?" ON)
if(LOGGING_FLAGS_CLIENT_HOOKS)
message( STATUS "Client hook loggers enabled")
math(EXPR LOGGING_FLAGS_ "${LOGGING_FLAGS_} | 0x2")
endif()
option(LOGGING_FLAGS_FILE_IO "Enable File IO loggers?" ON)
if(LOGGING_FLAGS_FILE_IO)
message( STATUS "File IO loggers enabled")
math(EXPR LOGGING_FLAGS_ "${LOGGING_FLAGS_} | 0x4")
endif()
option(LOGGING_FLAGS_FILE_IO_DETAILS "Enable File IO details loggers?" ON)
if(LOGGING_FLAGS_FILE_IO_DETAILS)
message( STATUS "File IO details loggers enabled")
math(EXPR LOGGING_FLAGS_ "${LOGGING_FLAGS_} | 0x8")
endif()
add_definitions(-DLOGGING_FLAGS=${LOGGING_FLAGS_})
# contract flags
set(CONTRACT_FLAGS_ 0x0)
option(CONTRACT_FLAGS_FILE_IO "Enable file IO contracts?" ON)
if(CONTRACT_FLAGS_FILE_IO)
message( STATUS "File IO contract validation enabled")
math(EXPR CONTRACT_FLAGS_ "${CONTRACT_FLAGS_} | 0x1")
endif()
option(CONTRACT_FLAGS_STORAGE "Enable storage contracts?" ON)
if(CONTRACT_FLAGS_STORAGE)
message( STATUS "Storage contract validation enabled")
math(EXPR CONTRACT_FLAGS_ "${CONTRACT_FLAGS_} | 0x2")
endif()
add_definitions(-DCONTRACT_FLAGS=${CONTRACT_FLAGS_})
# define base source dir path to use in compile time
add_definitions(-DSOURCE_DIR="${CMAKE_SOURCE_DIR}")
set(filters src/IO/ADT/Obj src/IO/ADT/Root src/IO/ADT/Tex)
collect_files(sources_files src TRUE "*.c;*.cpp;" "${filters}")
collect_files(headers_files src TRUE "*.h;*.hpp;*.inl" "")
assign_source_group(
${sources_files}
${headers_files}
)
#target
add_library(EpsilonAddon SHARED ${sources_files} ${headers_files})
target_compile_options(EpsilonAddon PRIVATE
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
-Wall -Wextra>
$<$<CXX_COMPILER_ID:MSVC>:
/W4>)
# dependencies
# stormlib
FetchContent_Declare(storm
GIT_REPOSITORY https://github.com/ladislav-zezula/StormLib.git
GIT_TAG master
)
FetchContent_GetProperties(storm)
if(NOT storm_POPULATED)
MESSAGE(STATUS "Installing StormLib...")
FetchContent_Populate(storm)
endif()
set(BUILD_SHARED_LIBS_SAVED "${BUILD_SHARED_LIBS}")
set(BUILD_SHARED_LIBS OFF)
set(STORM_SKIP_INSTALL "Skip installing files" ON)
add_subdirectory (${storm_SOURCE_DIR} ${storm_BINARY_DIR} EXCLUDE_FROM_ALL)
target_compile_definitions(EpsilonAddon PRIVATE STORMLIB_NO_AUTO_LINK)
set(BUILD_SHARED_LIBS "${BUILD_SHARED_LIBS_SAVED}")
# casclib
FetchContent_Declare(casc
GIT_REPOSITORY https://github.com/ladislav-zezula/CascLib.git
GIT_TAG master
)
FetchContent_GetProperties(casc)
if(NOT casc_POPULATED)
MESSAGE(STATUS "Installing CascLib...")
FetchContent_Populate(casc)
set(CASC_BUILD_SHARED_LIB OFF)
set(CASC_BUILD_STATIC_LIB ON)
add_subdirectory (${casc_SOURCE_DIR} ${casc_BINARY_DIR} EXCLUDE_FROM_ALL)
target_compile_definitions(EpsilonAddon PRIVATE CASCLIB_NO_AUTO_LINK_LIBRARY)
endif()
#boost
find_package(Boost 1.74.0 REQUIRED)
target_link_libraries(EpsilonAddon storm casc_static ${Boost_LIBRARIES})
set(EpsilonAddon_INCLUDE_DIRS
"src"
"${casc_SOURCE_DIR}/src"
"${storm_SOURCE_DIR}/src"
"${EXTERNAL_SOURCE_DIR}/MinHook/include"
"${EXTERNAL_SOURCE_DIR}/backward-cpp"
"${EXTERNAL_SOURCE_DIR}/bitpacker/include" "src"
"${EXTERNAL_SOURCE_DIR}/ordered-map/include"
"${EXTERNAL_SOURCE_DIR}/nameof/include"
"${Boost_INCLUDE_DIRS}")
target_include_directories(EpsilonAddon PRIVATE ${EpsilonAddon_INCLUDE_DIRS})
# tests
if(BUILD_TESTS)
message( STATUS "Building tests")
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
set(BUILD_SHARED_LIBS TRUE)
add_executable(logging_test "tests/LoggingTest.cpp")
target_link_libraries(logging_test EpsilonAddon)
target_include_directories(logging_test PRIVATE ${EpsilonAddon_INCLUDE_DIRS})
add_executable(contract_test "tests/ContractsTest.cpp")
target_link_libraries(contract_test EpsilonAddon)
target_include_directories(contract_test PRIVATE ${EpsilonAddon_INCLUDE_DIRS})
add_executable(storage_test "tests/StorageTest.cpp")
target_link_libraries(storage_test EpsilonAddon)
target_include_directories(storage_test PRIVATE ${EpsilonAddon_INCLUDE_DIRS})
add_executable(traits_test "tests/TraitsTest.cpp")
target_link_libraries(traits_test EpsilonAddon)
target_include_directories(traits_test PRIVATE ${EpsilonAddon_INCLUDE_DIRS})
add_executable(reflection_test "tests/ReflectionTest.cpp")
target_link_libraries(reflection_test EpsilonAddon)
target_include_directories(reflection_test PRIVATE ${EpsilonAddon_INCLUDE_DIRS})
add_executable(meta_algorithms_test "tests/MetaAlgorithms.cpp")
target_link_libraries(meta_algorithms_test EpsilonAddon)
target_include_directories(meta_algorithms_test PRIVATE ${EpsilonAddon_INCLUDE_DIRS})
endif()
# documentation
find_package(Doxygen)
if(DOXYGEN_FOUND)
message(STATUS "Doxygen found")
# set input and output files
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.out)
# request to configure the file
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
add_custom_target( docs
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM )
endif(DOXYGEN_FOUND)
# post build hooks
#[[
add_custom_command(TARGET EpsilonAddon POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${PROJECT_SOURCE_DIR}/src/shaders"
$<TARGET_FILE_DIR:EpsilonAddon>/shaders
COMMAND ${CMAKE_COMMAND} -E remove -f
$<TARGET_FILE_DIR:EpsilonAddon>/shaders/.git)
]]