/
premake4.lua
executable file
·265 lines (222 loc) · 6.22 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
-- Unit test
newoption {
trigger = "with-unittest",
description = "Build unit test."
}
-- Intel Embree
newoption {
trigger = "with-embree",
description = "Use Intel Embree ray tracing kernel."
}
-- ARM target
newoption {
trigger = "arm",
description = "Compile for ARM."
}
-- OpenMP
newoption {
trigger = "with-openmp",
description = "Use OpenMP."
}
-- MPI
newoption {
trigger = "with-mpi",
description = "Use MPI."
}
-- Ptex
newoption {
trigger = "with-ptex",
description = "Use Ptex library."
}
-- FITS
newoption {
trigger = "with-cfitsio",
description = "Use C-binding of FITS IO."
}
-- SDL
newoption {
trigger = "with-sdl",
description = "Use SDL2.0."
}
main_sources = {
"main.cc",
"main_console.cc",
"main_sdl.cc",
}
sources = {
"mmm_io.cc",
"render.cc",
"camera.cc",
"light.cc",
"matrix.cc",
"trackball.cc",
"prim-plane.cc",
"prim-plane.h",
"importers/tiny_obj_loader.cc",
"importers/tiny_obj_loader.h",
"importers/eson.cc",
"importers/eson.h",
"importers/magicavoxel_loader.cc",
"importers/magicavoxel_loader.h",
"importers/mesh_loader.cc",
"importers/mesh_loader.h",
"importers/mmd_scene.cc",
"importers/mmd_scene.h",
"importers/mmd_math.h",
"importers/vmd_animation.cc",
"importers/vmd_animation.h",
"importers/vmd_reader.cc",
"importers/vmd_reader.h",
"importers/pmd_reader.cc",
"importers/pmd_reader.h",
"importers/pmd_model.h",
"bvh_accel.cc",
"scene.cc",
"spectrum.cc",
"jpge.cc",
"deps/parson/parson.c",
"tasksys.cc",
"texture.cc",
"vcm.cc",
"script_engine.cc",
"deps/TinyThread++-1.1/source/tinythread.cpp",
"miniexr.cpp",
"tinyexr.cc",
"tinyexr.h",
"happyhttp.cpp",
"happyhttp.h",
"filepath_util.cc",
"filepath_util.h",
"duktape.c",
"duktape.h",
}
test_sources = {
"test/cctest/test-atomic.cc",
"test/cctest/test-main.cc"
}
gtest_sources = {
"deps/gtest-1.7.0/src/gtest-all.cc",
-- "deps/gtest-1.7.0/src/gtest_main.cc"
}
newaction {
trigger = "install",
description = "Install the software",
execute = function ()
-- copy files, etc. here
end
}
-- premake4.lua
solution "MallieSolution"
configurations { "Release", "Debug" }
if (os.is("windows")) then
platforms { "native", "x32", "x64" }
else
platforms { "native", "x32", "x64" }
end
-- A project defines one build target
project "Mallie"
kind "ConsoleApp"
language "C++"
files { main_sources, sources }
includedirs {
"./",
"deps/parson/",
"deps/TinyThread++-1.1/source/",
}
-- MacOSX. Guess we use gcc.
configuration { "macosx", "gmake" }
defines { '_LARGEFILE_SOURCE', '_FILE_OFFSET_BITS=64' }
if _OPTIONS['with-embree'] then
defines { "ENABLE_EMBREE" }
includedirs { "./deps/embree-bin-2.3.2_macos/include" }
libdirs { "./deps/embree-bin-2.3.2_macos/lib/x64" }
links { "embree" }
end
-- SDL
if _OPTIONS['with-sdl'] then
defines { 'ENABLE_SDL' }
buildoptions { "`./extlibs/macosx/SDL2/bin/sdl2-config --cflags`" }
buildoptions { "-msse2" }
linkoptions { "`./extlibs/macosx/SDL2/bin/sdl2-config --libs`" }
end
-- gcc openmp
if _OPTIONS['with-openmp'] then
buildoptions { "-fopenmp" }
linkoptions { "-fopenmp" }
end
-- gcc mpi
if _OPTIONS['with-mpi'] then
defines { 'WITH_MPI' }
end
-- Ptex
if _OPTIONS['with-ptex'] then
defines { 'ENABLE_PTEX' }
includedirs { "./deps/ptex-master/install/include" }
libdirs { "./deps/ptex-master/install/lib" }
links { "Ptex" }
end
-- Windows general
configuration { "windows" }
includedirs { "./compat" } -- stdint
if _OPTIONS['with-sdl'] then
defines { 'ENABLE_SDL' }
includedirs { "extlibs/windows/SDL2-2.0.3/include/" }
links { "SDL2", "SDL2main" }
libdirs { "extlibs/windows/SDL2-2.0.3/lib/x64/" }
end
defines { '_USE_MATH_DEFINES' }
defines { 'NOMINMAX', '_LARGEFILE_SOURCE', '_FILE_OFFSET_BITS=64' }
-- Windows + gmake specific
configuration { "windows", "gmake" }
defines { '__STDC_CONSTANT_MACROS', '__STDC_LIMIT_MACROS' } -- c99
links { "stdc++", "msvcrt", "ws2_32", "winmm" }
-- Linux specific
configuration {"linux", "gmake"}
defines { '__STDC_CONSTANT_MACROS', '__STDC_LIMIT_MACROS' } -- c99
if _OPTIONS['with-embree'] then
defines { "ENABLE_EMBREE" }
includedirs { "./deps/embree-bin-2.3.2_linux/include" }
libdirs { "./deps/embree-bin-2.3.2_linux/lib/x64" }
links { "embree" }
end
-- gcc openmp
if _OPTIONS['with-openmp'] then
buildoptions { "-fopenmp" }
linkoptions { "-fopenmp" }
else
links { "pthread" }
end
-- gcc mpi
if _OPTIONS['with-mpi'] then
defines { 'WITH_MPI' }
end
-- Ptex
if _OPTIONS['with-ptex'] then
defines { 'ENABLE_PTEX' }
includedirs { "./deps/ptex-master/install/include" }
libdirs { "./deps/ptex-master/install/lib" }
links { "Ptex" }
end
if _OPTIONS['with-sdl'] then
defines { 'ENABLE_SDL' }
buildoptions { "`./extlibs/linux/SDL2/bin/sdl2-config --cflags`" }
linkoptions { "`./extlibs/linux/SDL2/bin/sdl2-config --libs`" }
end
configuration "Debug"
defines { "DEBUG" } -- -DDEBUG
flags { "Symbols" }
targetdir "bin/"
targetname "mallie_debug"
configuration "Release"
defines { "NDEBUG" }
flags { "Symbols", "Optimize" }
if _OPTIONS['arm'] then
-- buildoptions { "NEON" }
else
flags { "EnableSSE2" }
end
targetdir "bin/"
targetname "mallie"
if _OPTIONS['with-unittest'] then
dofile "premake4-test.lua"
end