-
Notifications
You must be signed in to change notification settings - Fork 5
/
premake4.lua
445 lines (393 loc) · 11.8 KB
/
premake4.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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
-- vars
local win_unixenv = false
local cygwin = false
local mingw = false
local clang_libcxx = false
local gcc_compat = false
local cuda = false
local pocl = false
local windows_no_cmd = false
local gldrawpixels = false
local platform = "x32"
local system_includes = ""
-- this function returns the first result of "find basepath -name filename", this is needed on some platforms to determine the include path of a library
function find_include(filename, base_path)
if(os.is("windows") and not win_unixenv) then
return ""
end
local proc = io.popen("find "..base_path.." -name \""..filename.."\"", "r")
local path_names = proc:read("*a")
proc:close()
if(string.len(path_names) == 0) then
return ""
end
local newline = string.find(path_names, "\n")
if newline == nil then
return ""
end
return string.sub(path_names, 0, newline-1)
end
function add_include(path)
system_includes = system_includes.." -isystem "..path
end
-------------------------------------------------------------------------------
-- basic config for all projects
solution "oclraster"
-- scan args
local argc = 1
while(_ARGS[argc] ~= nil) do
if(_ARGS[argc] == "--env") then
argc=argc+1
-- check if we are building with cygwin/mingw
if(_ARGS[argc] ~= nil and _ARGS[argc] == "cygwin") then
cygwin = true
win_unixenv = true
end
if(_ARGS[argc] ~= nil and _ARGS[argc] == "mingw") then
mingw = true
win_unixenv = true
end
end
if(_ARGS[argc] == "--clang") then
clang_libcxx = true
end
if(_ARGS[argc] == "--gcc") then
gcc_compat = true
end
if(_ARGS[argc] == "--platform") then
argc=argc+1
if(_ARGS[argc] ~= nil) then
platform = _ARGS[argc]
end
end
if(_ARGS[argc] == "--cuda") then
cuda = true
end
if(_ARGS[argc] == "--pocl") then
pocl = true
end
if(_ARGS[argc] == "--windows") then
windows_no_cmd = true
end
if(_ARGS[argc] == "--internal-debug") then
defines { "OCLRASTER_INTERNAL_PROGRAM_DEBUG=1" }
end
if(_ARGS[argc] == "--cl-profiling") then
defines { "OCLRASTER_PROFILING=1" }
end
if(_ARGS[argc] == "--gldrawpixels") then
defines { "OCLRASTER_USE_DRAW_PIXELS=1" }
end
argc=argc+1
end
defines { "TCC_LIB_ONLY=1" }
if(pocl) then
defines { "OCLRASTER_POCL" }
end
configurations { "Release", "Debug" }
-- os specifics
if(not os.is("windows") or win_unixenv) then
if(not cygwin) then
add_include("/usr/include")
else
add_include("/usr/include/w32api")
add_include("/usr/include/w32api/GL")
end
add_include("/usr/local/include")
add_include("/usr/include/libxml2")
add_include("/usr/include/libxml")
add_include("/usr/local/include/libxml2")
add_include("/usr/include/freetype2")
add_include("/usr/local/include/freetype2")
buildoptions { "-std=c++1y" }
if(clang_libcxx) then
buildoptions { "-stdlib=libc++" }
buildoptions { "-Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-c99-extensions -Wno-header-hygiene" }
buildoptions { "-Wno-gnu -Wno-documentation -Wno-system-headers -Wno-global-constructors -Wno-padded -Wno-packed" }
buildoptions { "-Wno-switch-enum -Wno-exit-time-destructors -Wno-unknown-warning-option -Wno-nested-anon-types" }
linkoptions { "-fvisibility=default" }
if(not win_unixenv) then
defines { "FLOOR_EXPORT=1" }
linkoptions { "-stdlib=libc++" }
if(os.is("linux")) then
linkoptions { "-lc++abi" }
end
else
-- "--allow-multiple-definition" is necessary, because gcc is still used as a linker
-- and will always link against libstdc++ (-> multiple definitions with libc++)
-- also note: since libc++ is linked first, libc++'s functions will be used
linkoptions { "-stdlib=libc++ -lc++.dll -Wl,--allow-multiple-definition" }
end
end
if(gcc_compat) then
buildoptions { "-Wno-trigraphs -Wreturn-type -Wunused-variable -Wno-strict-aliasing" }
end
if(cuda) then
add_include("/usr/local/cuda/include")
add_include("/usr/local/cuda-5.5/include")
add_include("/opt/cuda/include")
add_include("/opt/cuda-5.5/include")
defines { "OCLRASTER_CUDA_CL=1" }
if(platform == "x64") then
libdirs { "/opt/cuda-toolkit/lib64", "/usr/local/cuda/lib64", "/usr/local/cuda-5.5/lib64", "/opt/cuda/lib64", "/opt/cuda-5.5/lib64" }
else
libdirs { "/opt/cuda-toolkit/lib", "/usr/local/cuda/lib", "/usr/local/cuda-5.5/lib", "/opt/cuda/lib", "/opt/cuda-5.5/lib" }
end
links { "cuda", "cudart" }
end
end
if(win_unixenv) then
defines { "WIN_UNIXENV" }
if(cygwin) then
defines { "CYGWIN" }
end
if(mingw) then
defines { "__WINDOWS__", "MINGW" }
add_include("/mingw/include")
buildoptions { "-Wno-unknown-pragmas" }
end
end
if(os.is("linux") or os.is("bsd") or win_unixenv) then
add_include("/usr/include/SDL2")
add_include("/usr/local/include/SDL2")
add_include("/usr/include/boost")
add_include("/usr/local/include/boost")
add_include("/usr/include/floor")
add_include("/usr/local/include/floor")
-- set system includes
buildoptions { system_includes }
libdirs { "/usr/lib", "/usr/local/lib" }
if(not pocl) then
links { "OpenCL" }
else
links { "pocl" }
end
libdirs { os.findlib("GL"), os.findlib("xml2"), os.findlib("OpenCL") }
if(not win_unixenv) then
links { "GL", "SDL2_image", "Xxf86vm", "xml2" }
libdirs { os.findlib("SDL2"), os.findlib("SDL2_image"), os.findlib("Xxf86vm") }
buildoptions { "`sdl2-config --cflags`" }
linkoptions { "`sdl2-config --libs`" }
elseif(cygwin) then
-- link against windows opengl libs on cygwin
links { "opengl32", "SDL2_image.dll", "xml2" }
libdirs { "/lib/w32api" }
buildoptions { "`sdl2-config --cflags | sed -E 's/-Dmain=SDL_main//g'`" }
linkoptions { "`sdl2-config --libs | sed -E 's/(-lmingw32|-mwindows)//g'`" }
elseif(mingw) then
-- link against windows opengl libs on mingw
links { "opengl32", "glu32", "gdi32", "SDL2_image", "libxml2", "pthread" }
buildoptions { "`sdl2-config --cflags | sed -E 's/-Dmain=SDL_main//g'`" }
if(windows_no_cmd) then
linkoptions { "`sdl2-config --libs`" }
else
-- no -mwindows flag -> creates a separate cmd window + working iostream output
linkoptions { "`sdl2-config --libs | sed -E 's/-mwindows//g'`" }
end
end
if(gcc_compat) then
if(not mingw) then
defines { "_GLIBCXX__PTHREADS" }
end
defines { "_GLIBCXX_USE_NANOSLEEP", "_GLIBCXX_USE_SCHED_YIELD" }
end
end
-- prefer system platform
if(platform == "x64") then
platforms { "x64", "x32" }
else
platforms { "x32", "x64" }
end
configuration { "x64" }
defines { "PLATFORM_X64" }
configuration { "x32" }
defines { "PLATFORM_X86" }
configuration "Release"
links { "floor" }
configuration "Debug"
links { "floord" }
-------------------------------------------------------------------------------
-- oclraster base lib
project "liboclraster"
-- project settings
targetname "liboclraster"
kind "SharedLib"
language "C++"
files { "lib/**.hpp", "lib/**.cpp" }
basedir "lib"
targetdir "bin"
includedirs { "lib/",
"lib/cl/",
"lib/core/",
"lib/hash/",
"lib/oclraster/",
"lib/pipeline/",
"lib/program/",
"lib/tccpp/",
"lib/threading/" }
if(not os.is("windows") or win_unixenv) then
prebuildcommands { "./build_version.sh" }
if(mingw) then
postbuildcommands { "./install.sh" }
end
end
configuration "Release"
targetname "oclraster"
defines { "NDEBUG" }
flags { "Optimize" }
if(not os.is("windows") or win_unixenv) then
buildoptions { "-O3 -ffast-math" }
end
configuration "Debug"
targetname "oclrasterd"
defines { "DEBUG", "OCLRASTER_DEBUG" }
flags { "Symbols" }
if(not os.is("windows") or win_unixenv) then
buildoptions { "-gdwarf-2" }
end
-- samples
project "oclr_simple"
targetname "oclr_simple"
kind "ConsoleApp"
language "C++"
files { "samples/oclr_simple/src/**.hpp", "samples/oclr_simple/src/**.cpp" }
basedir "samples/oclr_simple"
targetdir "bin"
includedirs { "/usr/include/oclraster",
"/usr/local/include/oclraster",
"samples/oclr_simple/src/" }
configuration "Release"
links { "oclraster" }
targetname "oclr_simple"
defines { "NDEBUG" }
flags { "Optimize" }
if(not os.is("windows") or win_unixenv) then
buildoptions { "-O3 -ffast-math" }
end
configuration "Debug"
links { "oclrasterd" }
targetname "oclr_simpled"
defines { "DEBUG", "OCLRASTER_DEBUG" }
flags { "Symbols" }
if(not os.is("windows") or win_unixenv) then
buildoptions { "-gdwarf-2" }
end
project "oclr_rtt"
targetname "oclr_rtt"
kind "ConsoleApp"
language "C++"
files { "samples/oclr_rtt/src/**.hpp", "samples/oclr_rtt/src/**.cpp" }
basedir "samples/oclr_rtt"
targetdir "bin"
includedirs { "/usr/include/oclraster",
"/usr/local/include/oclraster",
"samples/oclr_rtt/src/" }
configuration "Release"
links { "oclraster" }
targetname "oclr_rtt"
defines { "NDEBUG" }
flags { "Optimize" }
if(not os.is("windows") or win_unixenv) then
buildoptions { "-O3 -ffast-math" }
end
configuration "Debug"
links { "oclrasterd" }
targetname "oclr_rttd"
defines { "DEBUG", "OCLRASTER_DEBUG" }
flags { "Symbols" }
if(not os.is("windows") or win_unixenv) then
buildoptions { "-gdwarf-2" }
end
project "oclr_volume"
targetname "oclr_volume"
kind "ConsoleApp"
language "C++"
files { "samples/oclr_volume/src/**.hpp", "samples/oclr_volume/src/**.cpp" }
basedir "samples/oclr_volume"
targetdir "bin"
includedirs { "/usr/include/oclraster",
"/usr/local/include/oclraster",
"samples/oclr_volume/src/" }
configuration "Release"
links { "oclraster" }
targetname "oclr_volume"
defines { "NDEBUG" }
flags { "Optimize" }
if(not os.is("windows") or win_unixenv) then
buildoptions { "-O3 -ffast-math" }
end
configuration "Debug"
links { "oclrasterd" }
targetname "oclr_volumed"
defines { "DEBUG", "OCLRASTER_DEBUG" }
flags { "Symbols" }
if(not os.is("windows") or win_unixenv) then
buildoptions { "-gdwarf-2" }
end
-- oclraster_support lib and samples
project "liboclraster_support"
-- project settings
targetname "liboclraster_support"
kind "SharedLib"
language "C++"
files { "support/**.hpp", "support/**.cpp" }
basedir "support"
targetdir "bin"
includedirs { "support/",
"support/oclraster_support/",
"support/rendering/",
"support/gui/",
"/usr/include/oclraster",
"/usr/local/include/oclraster" }
links { "freetype" }
if(not os.is("windows") or win_unixenv) then
prebuildcommands { "./build_version.sh" }
if(mingw) then
-- TODO postbuildcommands { "./install.sh" }
end
end
configuration "Release"
links { "oclraster" }
targetname "oclraster_support"
defines { "NDEBUG" }
flags { "Optimize" }
if(not os.is("windows") or win_unixenv) then
buildoptions { "-O3 -ffast-math" }
end
configuration "Debug"
links { "oclrasterd" }
targetname "oclraster_supportd"
defines { "DEBUG", "OCLRASTER_DEBUG" }
flags { "Symbols" }
if(not os.is("windows") or win_unixenv) then
buildoptions { "-gdwarf-2" }
end
project "oclr_ui"
targetname "oclr_ui"
kind "ConsoleApp"
language "C++"
files { "samples/oclr_ui/src/**.hpp", "samples/oclr_ui/src/**.cpp" }
basedir "samples/oclr_ui"
targetdir "bin"
includedirs { "/usr/include/oclraster",
"/usr/include/oclraster_support",
"/usr/local/include/oclraster",
"/usr/local/include/oclraster_support",
"samples/oclr_ui/src/" }
links { "freetype" }
configuration "Release"
links { "oclraster", "oclraster_support" }
targetname "oclr_ui"
defines { "NDEBUG" }
flags { "Optimize" }
if(not os.is("windows") or win_unixenv) then
buildoptions { "-O3 -ffast-math" }
end
configuration "Debug"
links { "oclrasterd", "oclraster_supportd" }
targetname "oclr_uid"
defines { "DEBUG", "OCLRASTER_DEBUG" }
flags { "Symbols" }
if(not os.is("windows") or win_unixenv) then
buildoptions { "-gdwarf-2" }
end