-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
xmake.lua
268 lines (204 loc) · 6.95 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
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
includes(path.join(os.scriptdir(), "config.lua"))
local ObsFolder = ObsFolder or {}
rule("kinect_dynlib")
after_load(function (target)
target:add("rpathdirs", ".")
target:add("rpathdirs", "@executable_path")
end)
on_load("windows", function (target)
target:set("filename", target:name() .. ".dll")
end)
on_load("linux", function (target)
target:set("filename", target:name() .. ".so")
end)
on_load("macosx", function (target)
target:set("filename", target:name() .. ".dylib")
end)
rule_end()
rule("copy_to_obs")
after_build(function(target)
local folderKey = (is_mode("debug") and "Debug" or "Release") .. (is_arch("x86") and "32" or "64")
local obsDir = ObsFolder[folderKey]
if not obsDir then
return
end
local outputFolder
if target:name() == "obs-kinectcore" then
outputFolder = "bin"
else
outputFolder = "obs-plugins"
end
local archDir
if target:is_arch("x86_64", "x64") then
archDir = "64bit"
else
archDir = "32bit"
end
local outputdir = path.join(obsDir, outputFolder, archDir)
if outputdir and os.isdir(outputdir) then
for _, path in ipairs({ target:targetfile(), target:symbolfile() }) do
if os.isfile(path) then
os.vcp(path, outputdir)
end
end
end
end)
rule_end()
local function packageGen(outputFolder)
return function (target)
import("core.base.option")
local archDir
if target:is_arch("x86_64", "x64") then
archDir = "64bit"
else
archDir = "32bit"
end
local outputdir = path.join(option.get("outputdir") or config.buildir(), outputFolder, archDir)
for _, filepath in ipairs({ target:targetfile(), target:symbolfile() }) do
if os.isfile(filepath) then
os.vcp(filepath, path.join(outputdir, path.filename(filepath)))
end
end
end
end
rule("package_bin")
after_package(packageGen("bin"))
rule_end()
rule("package_plugin")
after_package(packageGen("obs-plugins"))
rule_end()
rule("package_backend")
if is_plat("windows") then
after_package(packageGen("bin"))
else
after_package(packageGen("obs-plugins"))
end
rule_end()
add_repositories("local-repo xmake-repo")
add_requires("libfreenect", "libfreenect2", { configs = { debug = is_mode("debug") } })
add_requires("k4a", "libusb")
add_requires("k4abt-headers", { optional = true })
add_requireconfs("libusb", "*.libusb", { configs = { pic = true, shared = is_plat("windows") }})
add_requireconfs("libfreenect2", "libfreenect2.libjpeg-turbo", { configs = { shared = not is_plat("windows") }})
if is_plat("windows") then
add_requires("kinect-sdk1", "kinect-sdk2", { optional = true })
add_requires("kinect-sdk1-toolkit", { optional = true, configs = { background_removal = true, facetrack = false, fusion = false, interaction = false, shared = true }})
end
set_project("obs-kinect")
set_version("1.0")
add_rules("mode.debug", "mode.releasedbg")
add_rules("plugin.vsxmake.autoupdate")
add_includedirs("include")
set_languages("c89", "cxx17")
set_license("GPL-3.0")
set_runtimes(is_mode("releasedbg") and "MD" or "MDd")
set_symbols("debug", "hidden")
set_targetdir("./bin/$(os)_$(arch)_$(mode)")
set_warnings("allextra")
add_sysincludedirs(LibObs.Include)
local baseObsDir = path.translate(is_arch("x86") and LibObs.Lib32 or LibObs.Lib64)
if is_plat("windows") then
for _, suffix in pairs(is_mode("debug") and {"Debug"} or {"Release", "RelWithDebInfo"}) do
local p = path.join(baseObsDir, suffix)
if (os.isdir(p)) then
add_linkdirs(p)
break
end
end
else
add_linkdirs(baseObsDir)
end
add_links("obs")
if is_plat("windows") then
add_defines("NOMINMAX", "WIN32_LEAN_AND_MEAN")
add_cxxflags("/Zc:__cplusplus", "/Zc:referenceBinding", "/Zc:throwingNew")
add_cxflags("/w44062") -- Enable warning: Switch case not handled warning
add_cxflags("/wd4251") -- Disable warning: class needs to have dll-interface to be used by clients of class blah blah blah
elseif is_plat("linux") then
add_syslinks("pthread")
end
-- Override default package function
on_package(function() end)
target("obs-kinectcore")
set_kind("shared")
set_group("Core")
add_defines("OBS_KINECT_CORE_EXPORT")
add_headerfiles("include/obs-kinect-core/**.hpp", "include/obs-kinect-core/**.inl")
add_headerfiles("src/obs-kinect-core/**.hpp", "src/obs-kinect-core/**.inl")
add_files("src/obs-kinect-core/**.cpp")
add_includedirs("src")
add_rules("copy_to_obs", "package_plugin")
target("obs-kinect")
set_kind("shared")
set_group("Core")
add_deps("obs-kinectcore")
add_headerfiles("src/obs-kinect/**.hpp", "src/obs-kinect/**.inl")
add_files("src/obs-kinect/**.cpp")
add_includedirs("src")
add_rules("kinect_dynlib", "copy_to_obs", "package_plugin")
on_package(function (target)
import("core.base.option")
local outputdir = option.get("outputdir") or config.buildir()
os.vcp("data", path.join(outputdir, "data"))
end)
target("obs-kinect-azuresdk")
set_kind("shared")
set_group("Azure")
add_deps("obs-kinectcore")
add_packages("k4a")
add_headerfiles("src/obs-kinect-azuresdk/**.hpp", "src/obs-kinect-azuresdk/**.inl")
add_files("src/obs-kinect-azuresdk/**.cpp")
add_rules("kinect_dynlib", "copy_to_obs", "package_backend")
if has_package("k4abt-headers") then
add_packages("k4abt-headers")
end
if is_plat("windows") then
if has_package("kinect-sdk1") then
target("obs-kinect-sdk10")
set_kind("shared")
set_group("KinectV1")
add_defines("UNICODE")
add_deps("obs-kinectcore")
add_packages("kinect-sdk1")
if has_package("kinect-sdk1-toolkit") then
add_packages("kinect-sdk1-toolkit", { links = {} })
end
add_headerfiles("src/obs-kinect-sdk10/**.hpp", "src/obs-kinect-sdk10/**.inl")
add_files("src/obs-kinect-sdk10/**.cpp")
add_rules("kinect_dynlib", "copy_to_obs", "package_backend")
end
if has_package("kinect-sdk2") then
target("obs-kinect-sdk20")
set_kind("shared")
set_group("KinectV2")
add_defines("UNICODE")
add_deps("obs-kinectcore")
add_packages("kinect-sdk2")
add_syslinks("Advapi32")
add_headerfiles("src/obs-kinect-sdk20/**.hpp", "src/obs-kinect-sdk20/**.inl")
add_files("src/obs-kinect-sdk20/**.cpp")
add_rules("kinect_dynlib", "copy_to_obs", "package_backend")
if not is_arch("x86") and os.isdir("thirdparty/NuiSensorLib") then
add_sysincludedirs("thirdparty/NuiSensorLib/include")
add_linkdirs("thirdparty/NuiSensorLib/lib/x64")
add_links("NuiSensorLib")
add_syslinks("SetupAPI")
end
end
end
target("obs-kinect-freenect")
set_kind("shared")
set_group("KinectV1")
add_deps("obs-kinectcore")
add_packages("libfreenect", "libusb")
add_headerfiles("src/obs-kinect-freenect/**.hpp", "src/obs-kinect-freenect/**.inl")
add_files("src/obs-kinect-freenect/**.cpp")
add_rules("kinect_dynlib", "copy_to_obs", "package_backend")
target("obs-kinect-freenect2")
set_kind("shared")
set_group("KinectV2")
add_deps("obs-kinectcore")
add_packages("libfreenect2")
add_headerfiles("src/obs-kinect-freenect2/**.hpp", "src/obs-kinect-freenect2/**.inl")
add_files("src/obs-kinect-freenect2/**.cpp")
add_rules("kinect_dynlib", "copy_to_obs", "package_backend")