forked from powerof3/CommonLibSSE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xmake.lua
190 lines (159 loc) · 7.09 KB
/
xmake.lua
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
-- set minimum xmake version
set_xmakever("2.8.2")
-- set project
set_project("commonlibsse")
set_arch("x64")
set_languages("c++23")
set_warnings("allextra")
set_encodings("utf-8")
-- add rules
add_rules("mode.debug", "mode.releasedbg")
-- make custom rules available
includes("xmake-rules.lua")
-- define options
option("rex_ini", function()
set_default(false)
set_description("Enable ini config support for REX")
add_defines("REX_OPTION_INI=1")
end)
option("rex_json", function()
set_default(false)
set_description("Enable json config support for REX")
add_defines("REX_OPTION_JSON=1")
end)
option("rex_toml", function()
set_default(false)
set_description("Enable toml config support for REX")
add_defines("REX_OPTION_TOML=1")
end)
option("skyrim_ae", function()
set_default(false)
set_description("Enable support for Skyrim AE")
add_defines("SKYRIM_SUPPORT_AE=1")
end)
option("skse_xbyak", function()
set_default(false)
set_description("Enable trampoline support for Xbyak")
add_defines("SKSE_SUPPORT_XBYAK=1")
end)
-- require packages
add_requires("rsm-binary-io")
add_requires("spdlog", { configs = { header_only = false, wchar = true, std_format = true } })
if has_config("rex_ini") then
add_requires("simpleini")
end
if has_config("rex_json") then
add_requires("nlohmann_json")
end
if has_config("rex_toml") then
add_requires("toml11")
end
if has_config("skse_xbyak") then
add_requires("xbyak")
end
-- define targets
target("commonlibsse", function()
-- set target kind
set_kind("static")
-- set build by default
set_default(os.scriptdir() == os.projectdir())
-- add packages
add_packages("rsm-binary-io", "spdlog", { public = true })
if has_config("rex_ini") then
add_packages("simpleini", { public = true })
end
if has_config("rex_json") then
add_packages("nlohmann_json", { public = true })
end
if has_config("rex_toml") then
add_packages("toml11", { public = true })
end
if has_config("skse_xbyak") then
add_packages("xbyak", { public = true })
end
-- add options
add_options("rex_ini", "rex_json", "rex_toml", "skyrim_ae", "skse_xbyak", { public = true })
-- add system links
add_syslinks("advapi32", "bcrypt", "d3d11", "d3dcompiler", "dbghelp", "dxgi", "ole32", "shell32", "user32", "version")
-- add source files
add_files("src/**.cpp")
-- add header files
add_includedirs("include", { public = true })
add_headerfiles(
"include/(RE/**.h)",
"include/(REL/**.h)",
"include/(REX/**.h)",
"include/(SKSE/**.h)"
)
-- set precompiled header
set_pcxxheader("include/SKSE/Impl/PCH.h")
-- add flags
add_cxxflags("/EHsc", "/permissive-", { public = true })
-- add flags (cl)
add_cxxflags(
"cl::/bigobj",
"cl::/cgthreads8",
"cl::/diagnostics:caret",
"cl::/external:W0",
"cl::/fp:contract",
"cl::/fp:except-",
"cl::/guard:cf-",
"cl::/Zc:enumTypes",
"cl::/Zc:preprocessor",
"cl::/Zc:templateScope"
)
-- add flags (cl: warnings -> errors)
add_cxxflags("cl::/we4715") -- `function` : not all control paths return a value
-- add flags (cl: disable warnings)
add_cxxflags(
"cl::/wd4005", -- macro redefinition
"cl::/wd4061", -- enumerator `identifier` in switch of enum `enumeration` is not explicitly handled by a case label
"cl::/wd4068", -- unknown pragma 'clang'
"cl::/wd4200", -- nonstandard extension used : zero-sized array in struct/union
"cl::/wd4201", -- nonstandard extension used : nameless struct/union
"cl::/wd4264", -- 'virtual_function' : no override available for virtual member function from base 'class'; function is hidden
"cl::/wd4265", -- 'type': class has virtual functions, but its non-trivial destructor is not virtual; instances of this class may not be destructed correctly
"cl::/wd4266", -- 'function' : no override available for virtual member function from base 'type'; function is hidden
"cl::/wd4324", -- 'struct_name' : structure was padded due to __declspec(align())
"cl::/wd4371", -- 'classname': layout of class may have changed from a previous version of the compiler due to better packing of member 'member'
"cl::/wd4514", -- 'function' : unreferenced inline function has been removed
"cl::/wd4582", -- 'type': constructor is not implicitly called
"cl::/wd4583", -- 'type': destructor is not implicitly called
"cl::/wd4623", -- 'derived class' : default constructor was implicitly defined as deleted because a base class default constructor is inaccessible or deleted
"cl::/wd4625", -- 'derived class' : copy constructor was implicitly defined as deleted because a base class copy constructor is inaccessible or deleted
"cl::/wd4626", -- 'derived class' : assignment operator was implicitly defined as deleted because a base class assignment operator is inaccessible or deleted
"cl::/wd4686", -- 'user-defined type' : possible change in behavior, change in UDT return calling convention
"cl::/wd4710", -- 'function' : function not inlined
"cl::/wd4711", -- function 'function' selected for inline expansion
"cl::/wd4820", -- 'bytes' bytes padding added after construct 'member_name'
"cl::/wd5082", -- second argument to 'va_start' is not the last named parameter
"cl::/wd5026", -- 'type': move constructor was implicitly defined as deleted
"cl::/wd5027", -- 'type': move assignment operator was implicitly defined as deleted
"cl::/wd5045", -- compiler will insert Spectre mitigation for memory load if /Qspectre switch specified
"cl::/wd5053", -- support for 'explicit(<expr>)' in C++17 and earlier is a vendor extension
"cl::/wd5105", -- macro expansion producing 'defined' has undefined behavior (workaround for older msvc bug)
"cl::/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
"cl::/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
)
-- add flags (clang-cl)
add_cxxflags(
"clang_cl::-fms-compatibility",
"clang_cl::-fms-extensions",
{ public = true }
)
-- add flags (clang-cl: disable warnings)
add_cxxflags(
"clang_cl::-Wno-delete-non-abstract-non-virtual-dtor",
"clang_cl::-Wno-deprecated-volatile",
"clang_cl::-Wno-ignored-qualifiers",
"clang_cl::-Wno-inconsistent-missing-override",
"clang_cl::-Wno-invalid-offsetof",
"clang_cl::-Wno-microsoft-include",
"clang_cl::-Wno-overloaded-virtual",
"clang_cl::-Wno-pragma-system-header-outside-header",
"clang_cl::-Wno-reinterpret-base-class",
"clang_cl::-Wno-switch",
"clang_cl::-Wno-unused-private-field",
{ public = true }
)
end)