-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
premake5.lua
271 lines (233 loc) · 6.22 KB
/
premake5.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
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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
Config = {}
setmetatable(Config, { __index = _G })
local configLoader, err = load(io.readfile("config.lua"), "config.lua", "t", Config)
if (not configLoader) then
error("config.lua failed to load: " .. err)
end
local configLoaded, err = pcall(configLoader)
if (not configLoaded) then
error("config.lua failed to load: " .. err)
end
local obsinclude = assert(Config.LibObs.Include, "Missing obs include dir")
local obslib32 = assert(Config.LibObs.Lib32, "Missing obs lib dir (x86)")
local obslib64 = assert(Config.LibObs.Lib64, "Missing obs lib dir (x86_64)")
local projects = {}
table.insert(projects, {
Name = "obs-kinect",
Defines = "OBS_KINECT_CORE_EXPORT",
Files = {
"include/obs-kinect/**.hpp",
"include/obs-kinect/**.inl",
"src/obs-kinect/**.hpp",
"src/obs-kinect/**.inl",
"src/obs-kinect/**.cpp"
},
Include = {
"include/obs-kinect",
"src/obs-kinect",
obsinclude
},
LibDir32 = obslib32,
LibDir64 = obslib64,
Links = "obs"
})
if (Config.KinectSdk10) then
local project = {
Name = "obs-kinect-sdk10",
Defines = {"WIN32", "_WINDOWS"},
Files = {
"src/obs-kinect-sdk10/**.hpp",
"src/obs-kinect-sdk10/**.inl",
"src/obs-kinect-sdk10/**.cpp"
},
Include = {
obsinclude,
"include/obs-kinect",
assert(Config.KinectSdk10.Include, "Missing KinectSdk10 include dir"),
Config.KinectSdk10Toolkit and Config.KinectSdk10Toolkit.Include or nil
},
Links = {
"obs-kinect",
"obs",
"Kinect10"
}
}
if (Config.KinectSdk10.Lib32) then
project.LibDir32 = {
obslib32,
Config.KinectSdk10.Lib32
}
else
print("Missing KinectSdk10 lib dir (x86)")
end
if (Config.KinectSdk10.Lib64) then
project.LibDir64 = {
obslib64,
Config.KinectSdk10.Lib64
}
else
print("Missing KinectSdk10 lib dir (x86_64)")
end
table.insert(projects, project)
else
print("Skipping KinectSdk10 backend")
end
if (Config.KinectSdk20) then
local project = {
Name = "obs-kinect-sdk20",
Files = {
"src/obs-kinect-sdk20/**.hpp",
"src/obs-kinect-sdk20/**.inl",
"src/obs-kinect-sdk20/**.cpp"
},
Include = {
obsinclude,
"include/obs-kinect",
assert(Config.KinectSdk20.Include, "Missing KinectSdk20 include dir")
},
Include64 = {
"thirdparty/NuiSensorLib/include"
},
LibDir32 = {},
LibDir64 = {
"thirdparty/NuiSensorLib/lib/x64"
},
Links = {
"obs-kinect",
"obs",
"kinect20"
},
Links64 = {
"NuiSensorLib",
"SetupAPI"
}
}
if (Config.KinectSdk20.Lib32) then
table.insert(project.LibDir32, obslib32)
table.insert(project.LibDir32, Config.KinectSdk20.Lib32)
else
print("Missing KinectSdk20 lib dir (x86)")
end
if (Config.KinectSdk20.Lib64) then
table.insert(project.LibDir64, obslib64)
table.insert(project.LibDir64, Config.KinectSdk20.Lib64)
else
print("Missing KinectSdk20 lib dir (x86_64)")
end
table.insert(projects, project)
else
print("Skipping KinectSdk20 backend")
end
if (Config.AzureKinectSdk) then
local project = {
Name = "obs-kinect-azuresdk",
Files = {
"src/obs-kinect-azuresdk/**.hpp",
"src/obs-kinect-azuresdk/**.inl",
"src/obs-kinect-azuresdk/**.cpp"
},
Include = {
obsinclude,
"include/obs-kinect",
assert(Config.AzureKinectSdk.Include, "Missing AzureKinectSdk include dir")
},
Links = {
"obs-kinect",
"obs",
"k4a"
}
}
if (Config.AzureKinectSdk.Lib32) then
project.LibDir32 = {
obslib32,
Config.AzureKinectSdk.Lib32
}
else
print("Missing AzureKinectSdk lib dir (x86)")
end
if (Config.AzureKinectSdk.Lib64) then
project.LibDir64 = {
obslib64,
Config.AzureKinectSdk.Lib64
}
else
print("Missing AzureKinectSdk lib dir (x86_64)")
end
if (Config.AzureKinectBodyTrackingSdk) then
table.insert(project.Include, Config.AzureKinectBodyTrackingSdk.Include)
else
print("Warning: AzureKinectSdk will not have body tracking support")
end
table.insert(projects, project)
else
print("Skipping AzureKinectSdk backend")
end
workspace("obs-kinect")
configurations({ "Debug", "Release" })
platforms({ "x86", "x86_64" })
if (_ACTION) then
location("build/" .. _ACTION)
end
-- Trigger premake before building, to automatically include new files (and premake changes)
if (os.ishost("windows")) then
local commandLine = "premake5.exe " .. table.concat(_ARGV, ' ')
prebuildcommands("cd ../.. && " .. commandLine)
end
for _, proj in pairs(projects) do
project(proj.Name)
kind("SharedLib")
language("C++")
cppdialect("C++17")
targetdir("bin/%{cfg.buildcfg}/%{cfg.architecture}")
defines(proj.Defines)
files(proj.Files)
includedirs(proj.Include)
links(proj.Links)
if (proj.LibDir32 and proj.LibDir64) then
platforms { "x86", "x86_64" }
elseif (proj.LibDir64) then
platforms "x86_64"
else
platforms "x86"
end
filter("system:Windows")
defines("NOMINMAX")
defines("WIN32_LEAN_AND_MEAN")
filter("action:vs*")
defines("_ENABLE_ATOMIC_ALIGNMENT_FIX")
disablewarnings("4251") -- class needs to have dll-interface to be used by clients of class blah blah blah
filter("platforms:x86")
architecture "x32"
includedirs(proj.Include32)
links(proj.Links32)
libdirs(proj.LibDir32)
filter("platforms:x86_64")
architecture "x64"
includedirs(proj.Include64)
links(proj.Links64)
libdirs(proj.LibDir64)
filter("configurations:Debug")
defines("DEBUG")
symbols("On")
filter("configurations:Release")
defines("NDEBUG")
omitframepointer("On")
optimize("Full")
symbols("On") -- Generate symbols in release too (helps in case of crash)
if (Config.CopyToDebug32) then
filter("configurations:Debug", "platforms:x86")
postbuildcommands({ "{COPY} %{cfg.buildtarget.abspath} " .. Config.CopyToDebug32 })
end
if (Config.CopyToDebug64) then
filter("configurations:Debug", "platforms:x86_64")
postbuildcommands({ "{COPY} %{cfg.buildtarget.abspath} " .. Config.CopyToDebug64 })
end
if (Config.CopyToRelease32) then
filter("configurations:Release", "platforms:x86")
postbuildcommands({ "{COPY} %{cfg.buildtarget.abspath} " .. Config.CopyToRelease32 })
end
if (Config.CopyToRelease64) then
filter("configurations:Release", "platforms:x86_64")
postbuildcommands({ "{COPY} %{cfg.buildtarget.abspath} " .. Config.CopyToRelease64 })
end
end