forked from SirLynix/obs-kinect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpremake5.lua
206 lines (175 loc) · 4.77 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
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")
},
Links = {
"obs-kinect",
"obs",
"kinect20"
}
}
if (Config.KinectSdk20.Lib32) then
project.LibDir32 = {
obslib32,
Config.KinectSdk20.Lib32
}
else
print("Missing KinectSdk20 lib dir (x86)")
end
if (Config.KinectSdk20.Lib64) then
project.LibDir64 = {
obslib64,
Config.KinectSdk20.Lib64
}
else
print("Missing KinectSdk20 lib dir (x86_64)")
end
table.insert(projects, project)
else
print("Skipping KinectSdk20 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("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"
libdirs(proj.LibDir32)
filter("platforms:x86_64")
architecture "x64"
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", "architecture:x32")
postbuildcommands({ "{COPY} %{cfg.buildtarget.abspath} " .. Config.CopyToDebug32 })
end
if (Config.CopyToDebug64) then
filter("configurations:Debug", "architecture:x64")
postbuildcommands({ "{COPY} %{cfg.buildtarget.abspath} " .. Config.CopyToDebug64 })
end
if (Config.CopyToRelease32) then
filter("configurations:Release", "architecture:x32")
postbuildcommands({ "{COPY} %{cfg.buildtarget.abspath} " .. Config.CopyToRelease32 })
end
if (Config.CopyToRelease64) then
filter("configurations:Release", "architecture:x64")
postbuildcommands({ "{COPY} %{cfg.buildtarget.abspath} " .. Config.CopyToRelease64 })
end
end