-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
178 lines (151 loc) · 5.85 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
cmake_minimum_required(VERSION 3.21)
# ---- Project ----
project(
LibTurtleClub
VERSION 1.0.1.1
HOMEPAGE_URL https://github.com/fireundubh/LibTurtleClub
LANGUAGES CXX
)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/version.rc.in
${CMAKE_CURRENT_BINARY_DIR}/version.rc
@ONLY
)
set(headers
src/PCH.h
src/Papyrus/Registration.h
src/Papyrus/PapyrusActor.h
src/Papyrus/PapyrusMisc.h
)
set(sources
src/main.cpp
src/PCH.cpp
src/Papyrus/Registration.cpp
src/Papyrus/PapyrusActor.cpp
src/Papyrus/PapyrusMisc.cpp
)
source_group(
TREE
${CMAKE_CURRENT_SOURCE_DIR}
FILES
${headers}
${sources}
)
# ---- Add CMake features ----
include(CheckIPOSupported)
include(GNUInstallDirs)
include(GoogleTest)
# ---- Dependencies ----
find_package(CommonLibSSE CONFIG REQUIRED)
find_package(binary_io REQUIRED)
find_package(spdlog REQUIRED)
find_package(fmt REQUIRED)
# ---- Configuration for all targets ----
if (MSVC)
add_compile_definitions(
UNICODE
_UNICODE
NOMINMAX
_AMD64_
WIN32_LEAN_AND_MEAN
_CRT_USE_BUILTIN_OFFSETOF # Fixes MSVC being non-compliant with offsetof behavior by default.
)
if ($ENV{CLION_IDE})
add_compile_definitions(
__cpp_lib_char8_t # Workaround for CLion bug.
__cpp_consteval # Workaround for CLion bug.
)
endif ()
add_compile_options(
/bigobj # support large object file format
/utf-8 # assume UTF-8 sources even without a BOM
# warnings -> errors
/we4715 # 'function' : not all control paths return a value
# disable warnings
/wd4005 # macro redefinition, needed for workarounds for CLion
/wd4061 # enumerator 'identifier' in switch of enum 'enumeration' is not explicitly handled by a case label
/wd4117 # definition of reserved macro, needed for workarounds for CLion
/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'
/wd4459 # declaration of 'identifier' hides global declaration
/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
)
endif ()
check_ipo_supported(RESULT USE_IPO OUTPUT IPO_OUTPUT)
if(USE_IPO)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION "$<$<CONFIG:RELEASE>:ON>")
endif()
# ---- Configure target DLL ----
add_commonlibsse_plugin(
${PROJECT_NAME}
AUTHOR
fireundubh
SOURCES
${headers}
${sources}
${CMAKE_CURRENT_BINARY_DIR}/version.rc
.clang-format
)
target_compile_features(
${PROJECT_NAME}
PUBLIC
cxx_std_23
)
target_compile_definitions(
${PROJECT_NAME}
PUBLIC
WINVER=0x0601 # windows 7, minimum supported version by skyrim special edition
_WIN32_WINNT=0x0601
"$<$<BOOL:${SKSE_SUPPORT_XBYAK}>:SKSE_SUPPORT_XBYAK=1>"
"$<$<BOOL:${ENABLE_SKYRIM_SE}>:ENABLE_SKYRIM_SE=1>"
"$<$<BOOL:${ENABLE_SKYRIM_AE}>:ENABLE_SKYRIM_AE=1>"
"$<$<BOOL:${ENABLE_SKYRIM_VR}>:ENABLE_SKYRIM_VR=1>"
)
target_include_directories(
${PROJECT_NAME}
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:src>
)
target_link_libraries(
${PROJECT_NAME}
PUBLIC
spdlog::spdlog
fmt::fmt
)
target_link_options(
${PROJECT_NAME}
PUBLIC
${LINK_OPTIONS_${CONFIG}}
)
target_precompile_headers(
${PROJECT_NAME}
PRIVATE
src/PCH.h
)
set(OUTPUT_ROOT "$ENV{SkyrimAE_Mods}/${PROJECT_NAME}" CACHE STRING "")
add_custom_command(
TARGET ${PROJECT_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:${PROJECT_NAME}> "${OUTPUT_ROOT}/SKSE/Plugins/"
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/Scripts/Source/${PROJECT_NAME}.psc "${OUTPUT_ROOT}/Scripts/Source/${PROJECT_NAME}.psc"
)