forked from ahzaab/moreHUDSE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
231 lines (190 loc) · 7.08 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
cmake_minimum_required(VERSION 3.19)
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "")
#set(VCPKG_OVERLAY_PORTS "${CMAKE_CURRENT_SOURCE_DIR}/ports" CACHE STRING "")
set(VCPKG_TARGET_TRIPLET "x64-windows-static-md" CACHE STRING "")
# ---- Project ----
project(
AHZmoreHUDPlugin
VERSION 5.0.1.0
LANGUAGES CXX
)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/Version.h.in
${CMAKE_CURRENT_BINARY_DIR}/include/Version.h
@ONLY
)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.rc.in
${CMAKE_CURRENT_BINARY_DIR}/version.rc
@ONLY
)
# ---- Include guards ----
if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
message(
FATAL_ERROR
"In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there."
)
endif()
# ---- Globals ----
add_compile_definitions(
SKSE_SUPPORT_XBYAK
)
if (MSVC)
add_compile_definitions(
_UNICODE
)
string(REPLACE " " ";" MY_CXX_FLAGS "${VCPKG_CXX_FLAGS}")
string(REPLACE " " ";" MY_CXX_FLAGS_DEBUG "${VCPKG_CXX_FLAGS_DEBUG}")
string(REPLACE " " ";" MY_CXX_FLAGS_RELEASE "${VCPKG_CXX_FLAGS_RELEASE}")
add_compile_options(
/MP # Build with Multiple Processes
/sdl # Enable Additional Security Checks
/Zi # Debug Information Format
/permissive- # Standards conformance
/Zc:alignedNew # C++17 over-aligned allocation
/Zc:auto # Deduce Variable Type
/Zc:char8_t
/Zc:__cplusplus # Enable updated __cplusplus macro
/Zc:externC
/Zc:externConstexpr # Enable extern constexpr variables
/Zc:forScope # Force Conformance in for Loop Scope
/Zc:hiddenFriend
/Zc:implicitNoexcept # Implicit Exception Specifiers
/Zc:lambda
/Zc:noexceptTypes # C++17 noexcept rules
/Zc:preprocessor # Enable preprocessor conformance mode
/Zc:referenceBinding # Enforce reference binding rules
/Zc:rvalueCast # Enforce type conversion rules
/Zc:sizedDealloc # Enable Global Sized Deallocation Functions
/Zc:strictStrings # Disable string literal type conversion
/Zc:ternary # Enforce conditional operator rules
/Zc:threadSafeInit # Thread-safe Local Static Initialization
/Zc:tlsGuards
/Zc:trigraphs # Trigraphs Substitution
/Zc:wchar_t # wchar_t Is Native Type
/experimental:external
/external:anglebrackets
# /external:W0
/W4 # Warning level
# /WX # Warning level (warnings are errors)
# warnings -> errors
/we4715 # 'function' : not all control paths return a value
# disable warnings
/wd4061 # enumerator 'identifier' in switch of enum 'enumeration' is not explicitly handled by a case label
/wd4200 # nonstandard extension used : zero-sized array in struct/union
/wd4201 # nonstandard extension used : nameless struct/union
/wd4265 # 'type': class has virtual functions, but its non-trivial destructor is not virtual; instances of this class may not be destructed correctly
/wd4266 # 'function' : no override available for virtual member function from base 'type'; function is hidden
/wd4371 # 'classname': layout of class may have changed from a previous version of the compiler due to better packing of member 'member'
/wd4514 # 'function' : unreferenced inline function has been removed
/wd4582 # 'type': constructor is not implicitly called
/wd4583 # 'type': destructor is not implicitly called
/wd4623 # 'derived class' : default constructor was implicitly defined as deleted because a base class default constructor is inaccessible or deleted
/wd4625 # 'derived class' : copy constructor was implicitly defined as deleted because a base class copy constructor is inaccessible or deleted
/wd4626 # 'derived class' : assignment operator was implicitly defined as deleted because a base class assignment operator is inaccessible or deleted
/wd4710 # 'function' : function not inlined
/wd4711 # function 'function' selected for inline expansion
/wd4820 # 'bytes' bytes padding added after construct 'member_name'
/wd5026 # 'type': move constructor was implicitly defined as deleted
/wd5027 # 'type': move assignment operator was implicitly defined as deleted
/wd5045 # Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified
/wd5053 # support for 'explicit(<expr>)' in C++17 and earlier is a vendor extension
/wd5204 # 'type-name': class has virtual functions, but its trivial destructor is not virtual; instances of objects derived from this class may not be destructed correctly
/wd5220 # 'member': a non-static data member with a volatile qualified type no longer implies that compiler generated copy / move constructors and copy / move assignment operators are not trivial
${MY_CXX_FLAGS}
"$<$<CONFIG:DEBUG>:${MY_CXX_FLAGS_DEBUG}>"
"$<$<CONFIG:RELEASE>:${MY_CXX_FLAGS_RELEASE};/Zc:inline;/JMC->"
)
# fix a warning with /Ob2 being overridden with /Ob3
string(REPLACE "/Ob2" "/Ob3" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
endif()
# ---- Dependencies ----
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_DEBUG OFF)
# set(Boost_USE_MULTITHREADED ON)
# set(Boost_USE_STATIC_LIBS ON)
# set(Boost_USE_STATIC_RUNTIME OFF)
# set(Boost_USE_DEBUG_RUNTIME ON)
add_subdirectory(external/CommonLibSSE)
# find_package(Boost
# REQUIRED
# COMPONENTS
# regex
# )
find_package(spdlog REQUIRED)
find_package(xbyak REQUIRED)
# ---- Add source files ----
include(cmake/headerlist.cmake)
include(cmake/sourcelist.cmake)
source_group(
TREE ${CMAKE_CURRENT_SOURCE_DIR}
FILES
${headers}
${sources}
)
source_group(
TREE ${CMAKE_CURRENT_BINARY_DIR}
FILES
${CMAKE_CURRENT_BINARY_DIR}/include/Version.h
)
# ---- Create DLL ----
add_library(
${PROJECT_NAME}
SHARED
${headers}
${sources}
${CMAKE_CURRENT_BINARY_DIR}/include/Version.h
${CMAKE_CURRENT_BINARY_DIR}/version.rc
.clang-format
)
set_property(
TARGET
${PROJECT_NAME}
CommonLibSSE
PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL"
)
target_compile_features(
${PROJECT_NAME}
PUBLIC
cxx_std_20
)
target_include_directories(
${PROJECT_NAME}
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/src
)
target_link_libraries(
${PROJECT_NAME}
PUBLIC
CommonLibSSE::CommonLibSSE
spdlog::spdlog
xbyak::xbyak
)
target_precompile_headers(
${PROJECT_NAME}
PRIVATE
include/PCH.h
)
if (MSVC)
target_compile_options(
${PROJECT_NAME}
PRIVATE
/wd4324 # 'struct_name' : structure was padded due to __declspec(align())
)
target_link_options(
${PROJECT_NAME}
PRIVATE
"$<$<CONFIG:DEBUG>:/INCREMENTAL;/OPT:NOREF;/OPT:NOICF>"
"$<$<CONFIG:RELEASE>:/INCREMENTAL:NO;/OPT:REF;/OPT:ICF;/DEBUG:FULL>"
)
endif()
# ---- Post build ----
add_custom_command(
TARGET ${PROJECT_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${PROJECT_NAME}> $ENV{Skyrim64AEPath}/Data/SKSE/Plugins/
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_PDB_FILE:${PROJECT_NAME}> $ENV{Skyrim64AEPath}/Data/SKSE/Plugins/
)