xmake.lua 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package("bullet3")
  2. set_homepage("http://bulletphysics.org")
  3. set_description("Bullet Physics SDK.")
  4. set_license("zlib")
  5. set_urls("https://github.com/bulletphysics/bullet3/archive/$(version).zip",
  6. "https://github.com/bulletphysics/bullet3.git")
  7. add_versions("2.88", "f361d10961021a186b80821cfc1cfafc8dac48ce35f7d5e8de0943af4b3ddce4")
  8. add_versions("3.05", "e7ef322d8038e397cd6d79145a856cf5b4d558ce091d49b5239d625a46fef0d7")
  9. add_versions("3.09", "8443894e47167cf7f7b4433a365b428ebeb83ba64d64f2a741ec4d2da4992c3d")
  10. add_versions("3.24", "1179bcc5cdaf7f73f92f5e8495eaadd6a7216e78cad22f1027e9ce49b7a0bfbe")
  11. add_versions("3.25", "b9bc8d1443637a9084e2b585ed582abf2da3ddad7d768acccfe4ee17aca56bf7")
  12. add_configs("double_precision", {description = "Enable double precision floats", default = false, type = "boolean"})
  13. add_configs("extras", {description = "Build the extras", default = false, type = "boolean"})
  14. if is_plat("windows", "mingw") then
  15. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  16. end
  17. add_deps("cmake")
  18. add_links("Bullet2FileLoader", "Bullet3Collision", "Bullet3Common", "Bullet3Dynamics", "Bullet3Geometry", "Bullet3OpenCL_clew", "BulletDynamics", "BulletCollision", "BulletInverseDynamics", "BulletSoftBody", "LinearMath")
  19. add_includedirs("include", "include/bullet")
  20. if is_plat("mingw") and is_subhost("msys") then
  21. add_extsources("pacman::bullet")
  22. elseif is_plat("linux") then
  23. add_extsources("pacman::bullet", "apt::libbullet-dev")
  24. elseif is_plat("macosx") then
  25. add_extsources("brew::bullet")
  26. end
  27. on_install(function (package)
  28. local configs = {"-DBUILD_CPU_DEMOS=OFF", "-DBUILD_OPENGL3_DEMOS=OFF", "-DBUILD_BULLET2_DEMOS=OFF", "-DBUILD_UNIT_TESTS=OFF", "-DINSTALL_LIBS=ON", "-DCMAKE_DEBUG_POSTFIX="}
  29. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  30. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  31. table.insert(configs, "-DUSE_DOUBLE_PRECISION=" .. (package:config("double_precision") and "ON" or "OFF"))
  32. table.insert(configs, "-DBUILD_EXTRAS=" .. (package:config("extras") and "ON" or "OFF"))
  33. table.insert(configs, "-DUSE_MSVC_RUNTIME_LIBRARY_DLL=ON") -- setting this to ON prevents Bullet from replacing flags
  34. if package:is_plat("windows") and not package:config("vs_runtime"):endswith("d") then
  35. table.insert(configs, "-DUSE_MSVC_RELEASE_RUNTIME_ALWAYS=ON") -- required to remove _DEBUG from cmake flags
  36. end
  37. import("package.tools.cmake").install(package, configs)
  38. end)
  39. on_test(function (package)
  40. assert(package:check_cxxsnippets({test = [[
  41. void test(int argc, char** argv) {
  42. btDefaultCollisionConfiguration collisionConfiguration;
  43. btCollisionDispatcher dispatcher(&collisionConfiguration);
  44. btDbvtBroadphase broadphase;
  45. btSequentialImpulseConstraintSolver constraintSolver;
  46. btDiscreteDynamicsWorld dynamicWorld(&dispatcher, &broadphase, &constraintSolver, &collisionConfiguration);
  47. dynamicWorld.setGravity(btVector3(0, -10, 0));
  48. broadphase.optimize();
  49. }
  50. ]]}, {includes = "bullet/btBulletDynamicsCommon.h"}))
  51. end)