1 ----------------------------------------------------------------------
2 -- Premake4 configuration script for OpenDE
3 -- Contributed by Jason Perkins (starkos@industriousone.com)
4 -- For more information on Premake: http://industriousone.com/premake
5 ----------------------------------------------------------------------
9 ----------------------------------------------------------------------
10 -- Demo list: add/remove demos from here and the rest of the build
12 ----------------------------------------------------------------------
50 local trimesh_demos
= {
59 if not _OPTIONS
["no-trimesh"] then
60 demos
= table.join(demos
, trimesh_demos
)
65 ----------------------------------------------------------------------
66 -- Configuration options
67 ----------------------------------------------------------------------
70 trigger
= "with-demos",
71 description
= "Builds the demo applications and DrawStuff library"
75 trigger
= "with-tests",
76 description
= "Builds the unit test application"
80 trigger
= "with-gimpact",
81 description
= "Use GIMPACT for trimesh collisions (experimental)"
85 trigger
= "all-collis-libs",
86 description
= "Include sources of all collision libraries into the project"
90 trigger
= "with-libccd",
91 description
= "Uses libccd for handling some collision tests absent in ODE."
96 description
= "Exclude DIF (Dynamics Interchange Format) exports"
100 trigger
= "no-trimesh",
101 description
= "Exclude trimesh collision geometry"
106 description
= "Use TLS for global caches (allows threaded collision checks for separated spaces)"
110 trigger
= "no-builtin-threading-impl",
111 description
= "Disable built-in multithreaded threading implementation"
115 trigger
= "no-threading-intf",
116 description
= "Disable threading interface support (external implementations cannot be assigned)"
120 trigger
= "16bit-indices",
121 description
= "Use 16-bit indices for trimeshes (default is 32-bit)"
125 trigger
= "old-trimesh",
126 description
= "Use old OPCODE trimesh-trimesh collider"
132 description
= "Set the output location for the generated project files"
136 trigger
= "only-shared",
137 description
= "Only build shared (DLL) version of the library"
141 trigger
= "only-static",
142 description
= "Only build static versions of the library"
146 trigger
= "only-single",
147 description
= "Only use single-precision math"
151 trigger
= "only-double",
152 description
= "Only use double-precision math"
157 description
= "Disable SSE2 use for x86 targets in favor to FPU"
160 -- always clean all of the optional components and toolsets
161 if _ACTION
== "clean" then
162 _OPTIONS
["with-demos"] = ""
163 _OPTIONS
["with-tests"] = ""
164 for action
in premake
.action
.each() do
165 os
.rmdir(action
.trigger
)
167 os
.remove("../ode/src/config.h")
168 os
.remove("../include/ode/version.h")
169 os
.remove("../include/ode/precision.h")
170 os
.remove("../libccd/src/ccd/precision.h")
173 -- special validation for Xcode
174 if _ACTION
== "xcode3" and (not _OPTIONS
["only-static"] and not _OPTIONS
["only-shared"]) then
176 "Xcode does not support different library types in a single project.\n" ..
177 "Please use one of the flags: --only-static or --only-shared", 0)
180 -- build the list of configurations, based on the flags. Ends up
181 -- with configurations like "Debug", "DebugSingle" or "DebugSingleShared"
182 local configs
= { "Debug", "Release" }
184 local function addconfigs(...)
185 local newconfigs
= { }
186 for _
, root
in ipairs(configs
) do
187 for _
, suffix
in ipairs(arg
) do
188 table.insert(newconfigs
, root
.. suffix
)
195 if not _OPTIONS
["only-single"] and not _OPTIONS
["only-double"] then
196 addconfigs("Single", "Double")
199 if not _OPTIONS
["only-shared"] and not _OPTIONS
["only-static"] then
200 addconfigs("DLL", "Lib")
204 ----------------------------------------------------------------------
205 -- The solution, and solution-wide settings
206 ----------------------------------------------------------------------
211 uuid
"4DA77C12-15E5-497B-B1BB-5100D5161E15"
212 location ( _OPTIONS
["to"] or _ACTION
)
221 -- apply the configuration list built above
222 configurations (configs
)
224 configuration
{ "Debug*" }
228 configuration
{ "Release*" }
229 defines
{ "NDEBUG", "dNODEBUG" }
230 flags
{ "OptimizeSpeed", "NoFramePointer" }
232 if not _OPTIONS
["no-sse2"] then
233 flags
{ "EnableSSE2" }
236 configuration
{ "*Single*" }
237 defines
{ "dIDESINGLE", "CCD_IDESINGLE" }
239 configuration
{ "*Double*" }
240 defines
{ "dIDEDOUBLE", "CCD_IDEDOUBLE" }
242 configuration
{ "Windows" }
245 configuration
{ "MacOSX" }
246 linkoptions
{ "-framework Carbon" }
248 -- give each configuration a unique output directory
249 for _
, name
in ipairs(configurations()) do
250 configuration
{ name
}
251 targetdir ( "../lib/" .. name
)
254 -- disable Visual Studio security warnings
255 configuration
{ "vs*" }
256 defines
{ "_CRT_SECURE_NO_DEPRECATE", "_SCL_SECURE_NO_WARNINGS" }
258 -- enable M_* macros from math.h
259 configuration
{ "vs*" }
260 defines
{ "_USE_MATH_DEFINES" }
262 -- don't remember why we had to do this
263 configuration
{ "vs2002 or vs2003", "*Lib" }
264 flags
{ "StaticRuntime" }
268 ----------------------------------------------------------------------
269 -- The demo projects, automated from list above. These go first so
270 -- they will be selected as the active project automatically in IDEs
271 ----------------------------------------------------------------------
273 if _OPTIONS
["with-demos"] then
274 for _
, name
in ipairs(demos
) do
276 project ( "demo_" .. name
)
278 if name
~= "ode" then
284 location ( _OPTIONS
["to"] or _ACTION
)
285 files
{ "../ode/demo/demo_" .. name
.. ".*" }
286 links
{ "ode", "drawstuff" }
288 configuration
{ "Windows" }
289 files
{ "../drawstuff/src/resources.rc" }
290 links
{ "user32", "winmm", "gdi32", "opengl32", "glu32" }
292 configuration
{ "MacOSX" }
293 linkoptions
{ "-framework Carbon -framework OpenGL -framework AGL" }
295 configuration
{ "not Windows", "not MacOSX" }
296 links
{ "GL", "GLU" }
303 ----------------------------------------------------------------------
304 -- The ODE library project
305 ----------------------------------------------------------------------
310 location ( _OPTIONS
["to"] or _ACTION
)
315 "../GIMPACT/include",
316 "../libccd/src/custom",
321 "../include/ode/*.h",
322 "../ode/src/joints/*.h",
323 "../ode/src/joints/*.cpp",
330 "../ode/src/collision_std.cpp",
333 includedirs
{ "../ou/include" }
334 files
{ "../ou/include/**.h", "../ou/src/**.h", "../ou/src/**.cpp" }
335 defines
{ "_OU_NAMESPACE=odeou" }
337 if _OPTIONS
["with-ou"] then
338 defines
{ "_OU_FEATURE_SET=_OU_FEATURE_SET_TLS" }
339 elseif not _OPTIONS
["no-threading-intf"] then
340 defines
{ "_OU_FEATURE_SET=_OU_FEATURE_SET_ATOMICS" }
342 defines
{ "_OU_FEATURE_SET=_OU_FEATURE_SET_BASICS" }
345 if _OPTIONS
["with-ou"] or not _OPTIONS
["no-threading-intf"] then
346 if _ACTION
== "gmake" then
347 if os
.get() == "windows" then
348 buildoptions
{ "-mthreads" }
349 linkoptions
{ "-mthreads" }
351 buildoptions
{ "-pthread" }
352 linkoptions
{ "-pthread" }
358 configuration
{ "no-dif" }
359 excludes
{ "../ode/src/export-dif.cpp" }
361 configuration
{ "no-trimesh" }
363 "../ode/src/collision_trimesh_colliders.h",
364 "../ode/src/gimpact_contact_export_helper.cpp",
365 "../ode/src/gimpact_contact_export_helper.h",
366 "../ode/src/gimpact_gim_contact_accessor.h",
367 "../ode/src/gimpact_plane_contact_accessor.h",
368 "../ode/src/collision_trimesh_internal.cpp",
369 "../ode/src/collision_trimesh_opcode.cpp",
370 "../ode/src/collision_trimesh_gimpact.cpp",
371 "../ode/src/collision_trimesh_box.cpp",
372 "../ode/src/collision_trimesh_ccylinder.cpp",
373 "../ode/src/collision_cylinder_trimesh.cpp",
374 "../ode/src/collision_trimesh_ray.cpp",
375 "../ode/src/collision_trimesh_sphere.cpp",
376 "../ode/src/collision_trimesh_trimesh.cpp",
377 "../ode/src/collision_trimesh_trimesh_old.cpp",
378 "../ode/src/collision_trimesh_plane.cpp",
379 "../ode/src/collision_convex_trimesh.cpp"
382 configuration
{ "not no-trimesh", "with-gimpact or all-collis-libs" }
383 files
{ "../GIMPACT/**.h", "../GIMPACT/**.cpp" }
385 configuration
{ "not no-trimesh", "not with-gimpact" }
386 files
{ "../OPCODE/**.h", "../OPCODE/**.cpp" }
388 configuration
{ "not no-trimesh", "not all-collis-libs", "with-gimpact" }
390 "../ode/src/collision_trimesh_opcode.cpp"
393 configuration
{ "not no-trimesh", "not all-collis-libs", "not with-gimpact" }
395 "../ode/src/gimpact_contact_export_helper.cpp",
396 "../ode/src/gimpact_contact_export_helper.h",
397 "../ode/src/gimpact_gim_contact_accessor.h",
398 "../ode/src/gimpact_plane_contact_accessor.h",
399 "../ode/src/collision_trimesh_gimpact.cpp"
402 configuration
{ "with-libccd" }
403 files
{ "../libccd/src/custom/ccdcustom/*.h", "../libccd/src/ccd/*.h", "../libccd/src/*.c" }
404 defines
{ "dLIBCCD_ENABLED", "dLIBCCD_INTERNAL",
405 "dLIBCCD_BOX_CYL", "dLIBCCD_CYL_CYL", "dLIBCCD_CAP_CYL", "dLIBCCD_CONVEX_BOX",
406 "dLIBCCD_CONVEX_CAP", "dLIBCCD_CONVEX_CYL", "dLIBCCD_CONVEX_SPHERE", "dLIBCCD_CONVEX_CONVEX" }
408 configuration
{ "not with-libccd" }
409 excludes
{ "../ode/src/collision_libccd.cpp", "../ode/src/collision_libccd.h" }
411 configuration
{ "windows" }
414 configuration
{ "only-static or *Lib" }
418 configuration
{ "only-shared or *DLL" }
422 configuration
{ "*DLL" }
425 configuration
{ "Debug" }
428 configuration
{ "Release" }
431 configuration
{ "DebugSingle*" }
432 targetname
"ode_singled"
434 configuration
{ "ReleaseSingle*" }
435 targetname
"ode_single"
437 configuration
{ "DebugDouble*" }
438 targetname
"ode_doubled"
440 configuration
{ "ReleaseDouble*" }
441 targetname
"ode_double"
444 ----------------------------------------------------------------------
445 -- Write a custom <config.h> to build, based on the supplied flags
446 ----------------------------------------------------------------------
448 if _ACTION
and _ACTION
~= "clean" then
449 local infile
= io
.open("config-default.h", "r")
450 local text
= infile
:read("*a")
452 if _OPTIONS
["no-trimesh"] then
453 text
= string.gsub(text
, "#define dTRIMESH_ENABLED 1", "/* #define dTRIMESH_ENABLED 1 */")
454 text
= string.gsub(text
, "#define dTRIMESH_OPCODE 1", "/* #define dTRIMESH_OPCODE 1 */")
455 elseif (_OPTIONS
["with-gimpact"]) then
456 text
= string.gsub(text
, "#define dTRIMESH_OPCODE 1", "#define dTRIMESH_GIMPACT 1")
459 text
= string.gsub(text
, "/%* #define dOU_ENABLED 1 %*/", "#define dOU_ENABLED 1")
460 if _OPTIONS
["with-ou"] or not _OPTIONS
["no-threading-intf"] then
461 text
= string.gsub(text
, "/%* #define dATOMICS_ENABLED 1 %*/", "#define dATOMICS_ENABLED 1")
464 if _OPTIONS
["with-ou"] then
465 text
= string.gsub(text
, "/%* #define dTLS_ENABLED 1 %*/", "#define dTLS_ENABLED 1")
468 if _OPTIONS
["no-threading-intf"] then
469 text
= string.gsub(text
, "/%* #define dTHREADING_INTF_DISABLED 1 %*/", "#define dTHREADING_INTF_DISABLED 1")
470 elseif not _OPTIONS
["no-builtin-threading-impl"] then
471 text
= string.gsub(text
, "/%* #define dBUILTIN_THREADING_IMPL_ENABLED 1 %*/", "#define dBUILTIN_THREADING_IMPL_ENABLED 1")
474 if _OPTIONS
["16bit-indices"] then
475 text
= string.gsub(text
, "#define dTRIMESH_16BIT_INDICES 0", "#define dTRIMESH_16BIT_INDICES 1")
478 if _OPTIONS
["old-trimesh"] then
479 text
= string.gsub(text
, "#define dTRIMESH_OPCODE_USE_OLD_TRIMESH_TRIMESH_COLLIDER 0", "#define dTRIMESH_OPCODE_USE_OLD_TRIMESH_TRIMESH_COLLIDER 1")
482 local outfile
= io
.open("../ode/src/config.h", "w")
487 ----------------------------
488 -- Write precision headers
489 ----------------------------
490 if _ACTION
and _ACTION
~= "clean" then
491 function generateheader(headerfile
, placeholder
, precstr
)
492 local outfile
= io
.open(headerfile
, "w")
493 for i
in io
.lines(headerfile
.. ".in")
495 local j
,_
= string.gsub(i
, placeholder
, precstr
)
496 --print("writing " .. j .. " into " .. headerfile)
497 outfile
:write(j
.. "\n")
502 function generate(precstr
)
503 generateheader("../include/ode/precision.h", "@ODE_PRECISION@", "d" .. precstr
)
504 generateheader("../libccd/src/ccd/precision.h", "@CCD_PRECISION@", "CCD_" .. precstr
)
507 if _OPTIONS
["only-single"] then
509 elseif _OPTIONS
["only-double"] then
512 generate("UNDEFINEDPRECISION")
515 generateheader("../include/ode/version.h", "@ODE_VERSION@", ode_version
)
520 ----------------------------------------------------------------------
521 -- The DrawStuff library project
522 ----------------------------------------------------------------------
524 if _OPTIONS
["with-demos"] then
528 location ( _OPTIONS
["to"] or _ACTION
)
531 "../include/drawstuff/*.h",
532 "../drawstuff/src/internal.h",
533 "../drawstuff/src/drawstuff.cpp"
536 configuration
{ "Debug*" }
537 targetname
"drawstuffd"
539 configuration
{ "only-static or *Lib" }
543 configuration
{ "only-shared or *DLL" }
545 defines
{ "DS_DLL", "USRDLL" }
547 configuration
{ "Windows" }
548 files
{ "../drawstuff/src/resource.h", "../drawstuff/src/resources.rc", "../drawstuff/src/windows.cpp" }
549 links
{ "user32", "opengl32", "glu32", "winmm", "gdi32" }
551 configuration
{ "MacOSX" }
552 defines
{ "HAVE_APPLE_OPENGL_FRAMEWORK" }
553 files
{ "../drawstuff/src/osx.cpp" }
554 linkoptions
{ "-framework Carbon -framework OpenGL -framework AGL" }
556 configuration
{ "not Windows", "not MacOSX" }
557 files
{ "../drawstuff/src/x11.cpp" }
558 links
{ "X11", "GL", "GLU" }
563 ----------------------------------------------------------------------
564 -- The automated test application
565 ----------------------------------------------------------------------
568 if _OPTIONS
["with-tests"] then
573 location ( _OPTIONS
["to"] or _ACTION
)
576 "../tests/UnitTest++/src"
581 "../tests/joints/*.cpp",
582 "../tests/UnitTest++/src/*"
587 configuration
{ "Windows" }
588 files
{ "../tests/UnitTest++/src/Win32/*" }
590 configuration
{ "not Windows" }
591 files
{ "../tests/UnitTest++/src/Posix/*" }
593 -- add post-build step to automatically run test executable
594 local path_to_lib
= path
.getrelative(location(), "../lib")
595 local command
= path
.translate(path
.join(path_to_lib
, "%s/tests"))
597 for _
, name
in ipairs(configurations()) do
598 configuration
{ name
}
599 postbuildcommands
{ command
:format(name
) }