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" }
350 defines
{ "HAVE_PTHREAD_ATTR_SETINHERITSCHED=1", "HAVE_PTHREAD_ATTR_SETSTACKLAZY=1" }
352 buildoptions
{ "-pthread" }
353 linkoptions
{ "-pthread" }
359 configuration
{ "no-dif" }
360 excludes
{ "../ode/src/export-dif.cpp" }
362 configuration
{ "no-trimesh" }
364 "../ode/src/collision_trimesh_colliders.h",
365 "../ode/src/gimpact_contact_export_helper.cpp",
366 "../ode/src/gimpact_contact_export_helper.h",
367 "../ode/src/gimpact_gim_contact_accessor.h",
368 "../ode/src/gimpact_plane_contact_accessor.h",
369 "../ode/src/collision_trimesh_internal.cpp",
370 "../ode/src/collision_trimesh_opcode.cpp",
371 "../ode/src/collision_trimesh_gimpact.cpp",
372 "../ode/src/collision_trimesh_box.cpp",
373 "../ode/src/collision_trimesh_ccylinder.cpp",
374 "../ode/src/collision_cylinder_trimesh.cpp",
375 "../ode/src/collision_trimesh_ray.cpp",
376 "../ode/src/collision_trimesh_sphere.cpp",
377 "../ode/src/collision_trimesh_trimesh.cpp",
378 "../ode/src/collision_trimesh_trimesh_old.cpp",
379 "../ode/src/collision_trimesh_plane.cpp",
380 "../ode/src/collision_convex_trimesh.cpp"
383 configuration
{ "not no-trimesh", "with-gimpact or all-collis-libs" }
384 files
{ "../GIMPACT/**.h", "../GIMPACT/**.cpp" }
386 configuration
{ "not no-trimesh", "not with-gimpact" }
387 files
{ "../OPCODE/**.h", "../OPCODE/**.cpp" }
389 configuration
{ "not no-trimesh", "not all-collis-libs", "with-gimpact" }
391 "../ode/src/collision_trimesh_opcode.cpp"
394 configuration
{ "not no-trimesh", "not all-collis-libs", "not with-gimpact" }
396 "../ode/src/gimpact_contact_export_helper.cpp",
397 "../ode/src/gimpact_contact_export_helper.h",
398 "../ode/src/gimpact_gim_contact_accessor.h",
399 "../ode/src/gimpact_plane_contact_accessor.h",
400 "../ode/src/collision_trimesh_gimpact.cpp"
403 configuration
{ "with-libccd" }
404 files
{ "../libccd/src/custom/ccdcustom/*.h", "../libccd/src/ccd/*.h", "../libccd/src/*.c" }
405 defines
{ "dLIBCCD_ENABLED", "dLIBCCD_INTERNAL",
406 "dLIBCCD_BOX_CYL", "dLIBCCD_CYL_CYL", "dLIBCCD_CAP_CYL", "dLIBCCD_CONVEX_BOX",
407 "dLIBCCD_CONVEX_CAP", "dLIBCCD_CONVEX_CYL", "dLIBCCD_CONVEX_SPHERE", "dLIBCCD_CONVEX_CONVEX" }
409 configuration
{ "not with-libccd" }
410 excludes
{ "../ode/src/collision_libccd.cpp", "../ode/src/collision_libccd.h" }
412 configuration
{ "windows" }
415 configuration
{ "only-static or *Lib" }
419 configuration
{ "only-shared or *DLL" }
423 configuration
{ "*DLL" }
426 configuration
{ "Debug" }
429 configuration
{ "Release" }
432 configuration
{ "DebugSingle*" }
433 targetname
"ode_singled"
435 configuration
{ "ReleaseSingle*" }
436 targetname
"ode_single"
438 configuration
{ "DebugDouble*" }
439 targetname
"ode_doubled"
441 configuration
{ "ReleaseDouble*" }
442 targetname
"ode_double"
445 ----------------------------------------------------------------------
446 -- Write a custom <config.h> to build, based on the supplied flags
447 ----------------------------------------------------------------------
449 if _ACTION
and _ACTION
~= "clean" then
450 local infile
= io
.open("config-default.h", "r")
451 local text
= infile
:read("*a")
453 if _OPTIONS
["no-trimesh"] then
454 text
= string.gsub(text
, "#define dTRIMESH_ENABLED 1", "/* #define dTRIMESH_ENABLED 1 */")
455 text
= string.gsub(text
, "#define dTRIMESH_OPCODE 1", "/* #define dTRIMESH_OPCODE 1 */")
456 elseif (_OPTIONS
["with-gimpact"]) then
457 text
= string.gsub(text
, "#define dTRIMESH_OPCODE 1", "#define dTRIMESH_GIMPACT 1")
460 text
= string.gsub(text
, "/%* #define dOU_ENABLED 1 %*/", "#define dOU_ENABLED 1")
461 if _OPTIONS
["with-ou"] or not _OPTIONS
["no-threading-intf"] then
462 text
= string.gsub(text
, "/%* #define dATOMICS_ENABLED 1 %*/", "#define dATOMICS_ENABLED 1")
465 if _OPTIONS
["with-ou"] then
466 text
= string.gsub(text
, "/%* #define dTLS_ENABLED 1 %*/", "#define dTLS_ENABLED 1")
469 if _OPTIONS
["no-threading-intf"] then
470 text
= string.gsub(text
, "/%* #define dTHREADING_INTF_DISABLED 1 %*/", "#define dTHREADING_INTF_DISABLED 1")
471 elseif not _OPTIONS
["no-builtin-threading-impl"] then
472 text
= string.gsub(text
, "/%* #define dBUILTIN_THREADING_IMPL_ENABLED 1 %*/", "#define dBUILTIN_THREADING_IMPL_ENABLED 1")
475 if _OPTIONS
["16bit-indices"] then
476 text
= string.gsub(text
, "#define dTRIMESH_16BIT_INDICES 0", "#define dTRIMESH_16BIT_INDICES 1")
479 if _OPTIONS
["old-trimesh"] then
480 text
= string.gsub(text
, "#define dTRIMESH_OPCODE_USE_OLD_TRIMESH_TRIMESH_COLLIDER 0", "#define dTRIMESH_OPCODE_USE_OLD_TRIMESH_TRIMESH_COLLIDER 1")
483 local outfile
= io
.open("../ode/src/config.h", "w")
488 ----------------------------
489 -- Write precision headers
490 ----------------------------
491 if _ACTION
and _ACTION
~= "clean" then
492 function generateheader(headerfile
, placeholder
, precstr
)
493 local outfile
= io
.open(headerfile
, "w")
494 for i
in io
.lines(headerfile
.. ".in")
496 local j
,_
= string.gsub(i
, placeholder
, precstr
)
497 --print("writing " .. j .. " into " .. headerfile)
498 outfile
:write(j
.. "\n")
503 function generate(precstr
)
504 generateheader("../include/ode/precision.h", "@ODE_PRECISION@", "d" .. precstr
)
505 generateheader("../libccd/src/ccd/precision.h", "@CCD_PRECISION@", "CCD_" .. precstr
)
508 if _OPTIONS
["only-single"] then
510 elseif _OPTIONS
["only-double"] then
513 generate("UNDEFINEDPRECISION")
516 generateheader("../include/ode/version.h", "@ODE_VERSION@", ode_version
)
521 ----------------------------------------------------------------------
522 -- The DrawStuff library project
523 ----------------------------------------------------------------------
525 if _OPTIONS
["with-demos"] then
529 location ( _OPTIONS
["to"] or _ACTION
)
532 "../include/drawstuff/*.h",
533 "../drawstuff/src/internal.h",
534 "../drawstuff/src/drawstuff.cpp"
537 configuration
{ "Debug*" }
538 targetname
"drawstuffd"
540 configuration
{ "only-static or *Lib" }
544 configuration
{ "only-shared or *DLL" }
546 defines
{ "DS_DLL", "USRDLL" }
548 configuration
{ "Windows" }
549 files
{ "../drawstuff/src/resource.h", "../drawstuff/src/resources.rc", "../drawstuff/src/windows.cpp" }
550 links
{ "user32", "opengl32", "glu32", "winmm", "gdi32" }
552 configuration
{ "MacOSX" }
553 defines
{ "HAVE_APPLE_OPENGL_FRAMEWORK" }
554 files
{ "../drawstuff/src/osx.cpp" }
555 linkoptions
{ "-framework Carbon -framework OpenGL -framework AGL" }
557 configuration
{ "not Windows", "not MacOSX" }
558 files
{ "../drawstuff/src/x11.cpp" }
559 links
{ "X11", "GL", "GLU" }
564 ----------------------------------------------------------------------
565 -- The automated test application
566 ----------------------------------------------------------------------
569 if _OPTIONS
["with-tests"] then
574 location ( _OPTIONS
["to"] or _ACTION
)
578 "../tests/UnitTest++/src"
583 "../tests/joints/*.cpp",
584 "../tests/UnitTest++/src/*"
589 configuration
{ "Windows" }
590 files
{ "../tests/UnitTest++/src/Win32/*" }
592 configuration
{ "not Windows" }
593 files
{ "../tests/UnitTest++/src/Posix/*" }
595 -- add post-build step to automatically run test executable
596 local path_to_lib
= path
.getrelative(location(), "../lib")
597 local command
= path
.translate(path
.join(path_to_lib
, "%s/tests"))
599 for _
, name
in ipairs(configurations()) do
600 configuration
{ name
}
601 postbuildcommands
{ command
:format(name
) }