premake4.lua 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  1. solution "0_Bullet3Solution"
  2. local osversion = os.getversion()
  3. print(string.format(" %d.%d.%d (%s)",
  4. osversion.majorversion, osversion.minorversion, osversion.revision,
  5. osversion.description))
  6. if _ACTION == "vs2010" or _ACTION=="vs2008" then
  7. buildoptions
  8. {
  9. -- Multithreaded compiling
  10. "/MP",
  11. -- Disable a few useless warnings
  12. "/wd4244",
  13. "/wd4267"
  14. }
  15. end
  16. act = ""
  17. if _ACTION then
  18. act = _ACTION
  19. end
  20. projectRootDir = os.getcwd() .. "/../"
  21. print("Project root directory: " .. projectRootDir);
  22. newoption {
  23. trigger = "ios",
  24. description = "Enable iOS target (requires xcode4)"
  25. }
  26. newoption
  27. {
  28. trigger = "enable_system_glx",
  29. description = "Try to link against system glx instead of using glad_glx (default)"
  30. }
  31. newoption
  32. {
  33. trigger = "enable_system_opengl",
  34. description = "Try to link and use the system OpenGL headers version instead of dynamically loading OpenGL (dlopen is default)"
  35. }
  36. newoption
  37. {
  38. trigger = "enable_openvr",
  39. description = "Enable experimental Virtual Reality examples, using OpenVR for HTC Vive and Oculus Rift"
  40. }
  41. newoption
  42. {
  43. trigger = "enable_system_x11",
  44. description = "Try to link and use system X11 headers instead of dynamically loading X11 (dlopen is default)"
  45. }
  46. newoption
  47. {
  48. trigger = "enable_stable_pd",
  49. description = "Enable Stable PD control in PyBullet"
  50. }
  51. newoption
  52. {
  53. trigger = "enable_static_vr_plugin",
  54. description = "Statically link vr plugin (in examples/SharedMemory/plugins/vrSyncPlugin)"
  55. }
  56. newoption
  57. {
  58. trigger = "enable_static_test_plugin",
  59. description = "Statically link test plugin (in examples/SharedMemory/plugins/testPlugin)"
  60. }
  61. newoption
  62. {
  63. trigger = "enable_static_tiny_renderer__plugin",
  64. description = "Statically link vr plugin (in examples/SharedMemory/plugins/tinyRendererPlugin)"
  65. }
  66. newoption
  67. {
  68. trigger = "enable_static_pd_control_plugin",
  69. description = "Statically link vr plugin (in examples/SharedMemory/plugins/pdControlPlugin)"
  70. }
  71. newoption
  72. {
  73. trigger = "enable_static_collision_filter_plugin",
  74. description = "Statically link vr plugin (in examples/SharedMemory/plugins/collisionFilterPlugin)"
  75. }
  76. newoption
  77. {
  78. trigger = "enable_physx",
  79. description = "Allow optional PhysX backend for PyBullet, use pybullet.connect(pybullet.PhysX)."
  80. }
  81. newoption
  82. {
  83. trigger = "noopengl3",
  84. description = "Don't compile any OpenGL3+ code"
  85. }
  86. newoption
  87. {
  88. trigger = "midi",
  89. description = "Use Midi controller to control parameters"
  90. }
  91. newoption
  92. {
  93. trigger = "enable_egl",
  94. value = false,
  95. description = "Build an experimental eglPlugin"
  96. }
  97. newoption
  98. {
  99. trigger = "enable_grpc",
  100. description = "Build GRPC server/client features for PyBullet/BulletRobotics"
  101. }
  102. if os.is("Linux") then
  103. default_grpc_include_dir = "usr/local/include/GRPC"
  104. default_grpc_lib_dir = "/usr/local/lib"
  105. default_protobuf_include_dir = "/usr/local/include/protobuf"
  106. default_protobuf_lib_dir = "/usr/local/lib"
  107. end
  108. if os.is("macosx") then
  109. default_grpc_include_dir = "/usr/local/Cellar/grpc/1.14.1/include"
  110. default_grpc_lib_dir = "/usr/local/Cellar/grpc/1.14.1/lib"
  111. default_protobuf_include_dir = "/usr/local/Cellar/protobuf/3.6.0/include"
  112. default_protobuf_lib_dir = "/usr/local/Cellar/protobuf/3.6.0/lib"
  113. end
  114. if os.is("Windows") then
  115. default_grpc_include_dir = projectRootDir .. "examples/ThirdPartyLibs/grpc/include"
  116. default_grpc_lib_dir = projectRootDir .. "examples/ThirdPartyLibs/grpc/lib"
  117. default_protobuf_include_dir =projectRootDir .. "examples/ThirdPartyLibs/grpc/include"
  118. default_protobuf_lib_dir = projectRootDir .. "examples/ThirdPartyLibs/grpc/lib"
  119. end
  120. newoption
  121. {
  122. trigger = "grpc_include_dir",
  123. value = default_grpc_include_dir,
  124. description = "(optional) GRPC include directory"
  125. }
  126. newoption
  127. {
  128. trigger = "grpc_lib_dir",
  129. value = default_grpc_lib_dir,
  130. description = "(optional) GRPC library directory "
  131. }
  132. newoption
  133. {
  134. trigger = "protobuf_include_dir",
  135. value = default_protobuf_include_dir,
  136. description = "(optional) protobuf include directory"
  137. }
  138. newoption
  139. {
  140. trigger = "protobuf_lib_dir",
  141. value = default_protobuf_lib_dir,
  142. description = "(optional) protobuf library directory "
  143. }
  144. if not _OPTIONS["grpc_lib_dir"] then
  145. _OPTIONS["grpc_lib_dir"] = default_grpc_lib_dir
  146. end
  147. if not _OPTIONS["grpc_include_dir"] then
  148. _OPTIONS["grpc_include_dir"] = default_grpc_include_dir
  149. end
  150. if not _OPTIONS["protobuf_include_dir"] then
  151. _OPTIONS["protobuf_include_dir"] = default_protobuf_include_dir
  152. end
  153. if not _OPTIONS["protobuf_lib_dir"] then
  154. _OPTIONS["protobuf_lib_dir"] = default_protobuf_lib_dir
  155. end
  156. if _OPTIONS["enable_egl"] then
  157. function initEGL()
  158. defines {"BT_USE_EGL"}
  159. end
  160. end
  161. if _OPTIONS["enable_grpc"] then
  162. function initGRPC()
  163. print "BT_ENABLE_GRPC"
  164. print("grpc_include_dir=")
  165. print(_OPTIONS["grpc_include_dir"])
  166. print("grpc_lib_dir=")
  167. print(_OPTIONS["grpc_lib_dir"])
  168. print("protobuf_include_dir=")
  169. print(_OPTIONS["protobuf_include_dir"])
  170. print("protobuf_lib_dir=")
  171. print(_OPTIONS["protobuf_lib_dir"])
  172. defines {"BT_ENABLE_GRPC"}
  173. if os.is("macosx") then
  174. buildoptions { "-std=c++11" }
  175. links{ "dl"}
  176. end
  177. if os.is("Linux") then
  178. buildoptions { "-std=c++11" }
  179. links{ "dl"}
  180. end
  181. if os.is("Windows") then
  182. defines {"_WIN32_WINNT=0x0600"}
  183. links{ "zlibstatic","ssl","crypto"}
  184. end
  185. includedirs {
  186. projectRootDir .. "examples", _OPTIONS["grpc_include_dir"], _OPTIONS["protobuf_include_dir"],
  187. }
  188. if os.is("Windows") then
  189. configuration {"x64", "debug"}
  190. libdirs {_OPTIONS["grpc_lib_dir"] .. "/win64_debug" , _OPTIONS["protobuf_lib_dir"] .. "win64_debug",}
  191. configuration {"x86", "debug"}
  192. libdirs {_OPTIONS["grpc_lib_dir"] .. "/win32_debug" , _OPTIONS["protobuf_lib_dir"] .. "win32_debug",}
  193. configuration {"x64", "release"}
  194. libdirs {_OPTIONS["grpc_lib_dir"] .. "/win64_release", _OPTIONS["protobuf_lib_dir"] .. "win64_release",}
  195. configuration {"x86", "release"}
  196. libdirs {_OPTIONS["grpc_lib_dir"] .. "/win32_release" , _OPTIONS["protobuf_lib_dir"] .. "win32_release",}
  197. configuration{}
  198. else
  199. libdirs {_OPTIONS["grpc_lib_dir"], _OPTIONS["protobuf_lib_dir"],}
  200. end
  201. links { "grpc","grpc++", "grpc++_reflection", "gpr", "protobuf"}
  202. files {
  203. projectRootDir .. "examples/SharedMemory/grpc/ConvertGRPCBullet.cpp",
  204. projectRootDir .. "examples/SharedMemory/grpc/ConvertGRPCBullet.h",
  205. projectRootDir .. "examples/SharedMemory/grpc/proto/pybullet.grpc.pb.cpp",
  206. projectRootDir .. "examples/SharedMemory/grpc/proto/pybullet.grpc.pb.h",
  207. projectRootDir .. "examples/SharedMemory/grpc/proto/pybullet.pb.cpp",
  208. projectRootDir .. "examples/SharedMemory/grpc/proto/pybullet.pb.h", }
  209. end
  210. end
  211. -- _OPTIONS["midi"] = "1";
  212. newoption
  213. {
  214. trigger = "no-demos",
  215. description = "Don't build demos"
  216. }
  217. newoption
  218. {
  219. trigger = "no-extras",
  220. description = "Don't build Extras"
  221. }
  222. newoption
  223. {
  224. trigger = "standalone-examples",
  225. description = "Build standalone examples with reduced dependencies."
  226. }
  227. newoption
  228. {
  229. trigger = "no-clsocket",
  230. description = "Disable clsocket and clsocket tests (used for optional TCP networking in pybullet and shared memory C-API)"
  231. }
  232. newoption
  233. {
  234. trigger = "no-enet",
  235. description = "Disable enet and enet tests (used for optional UDP networking in pybullet and shared memory C-API)"
  236. }
  237. newoption
  238. {
  239. trigger = "lua",
  240. description = "Enable Lua scipting support in Example Browser"
  241. }
  242. newoption
  243. {
  244. trigger = "enable_pybullet",
  245. description = "Enable high-level Python scripting of Bullet with URDF/SDF import and synthetic camera."
  246. }
  247. if os.is("Linux") then
  248. default_python_include_dir = "/usr/include/python2.7"
  249. default_python_lib_dir = "/usr/local/lib/"
  250. end
  251. if os.is("Windows") then
  252. default_python_include_dir = "C:/Python-3.5.2/include"
  253. default_python_lib_dir = "C:/Python-3.5.2/libs"
  254. end
  255. newoption
  256. {
  257. trigger = "python_include_dir",
  258. value = default_python_include_dir,
  259. description = "Python (2.x or 3.x) include directory"
  260. }
  261. newoption
  262. {
  263. trigger = "python_lib_dir",
  264. value = default_python_lib_dir,
  265. description = "Python (2.x or 3.x) library directory "
  266. }
  267. newoption {
  268. trigger = "targetdir",
  269. value = "path such as ../bin",
  270. description = "Set the output location for the generated project files"
  271. }
  272. newoption
  273. {
  274. trigger = "no-test",
  275. description = "Disable all tests"
  276. }
  277. newoption
  278. {
  279. trigger = "test-bullet2",
  280. description = "Enable Bullet2 LinearMath test"
  281. }
  282. newoption
  283. {
  284. trigger = "no-gtest",
  285. description = "Disable unit tests using gtest"
  286. }
  287. newoption
  288. {
  289. trigger = "no-bullet3",
  290. description = "Do not build bullet3 libs"
  291. }
  292. newoption
  293. {
  294. trigger = "double",
  295. description = "Double precision version of Bullet"
  296. }
  297. newoption
  298. {
  299. trigger = "clamp-velocities",
  300. description = "Limit maximum velocities to reduce FP exception risk"
  301. }
  302. newoption
  303. {
  304. trigger = "serial",
  305. description = "Enable serial, for testing the VR glove in C++"
  306. }
  307. newoption
  308. {
  309. trigger = "audio",
  310. description = "Enable audio"
  311. }
  312. newoption
  313. {
  314. trigger = "enable_multithreading",
  315. description = "enable CPU multithreading for bullet2 libs"
  316. }
  317. if _OPTIONS["enable_multithreading"] then
  318. defines {"BT_THREADSAFE=1"}
  319. end
  320. if _OPTIONS["double"] then
  321. defines {"BT_USE_DOUBLE_PRECISION"}
  322. end
  323. if _OPTIONS["clamp-velocities"] then
  324. defines {"BT_CLAMP_VELOCITY_TO=9999"}
  325. end
  326. newoption
  327. {
  328. trigger = "dynamic-runtime",
  329. description = "Enable dynamic DLL CRT runtime"
  330. }
  331. configurations {"Release", "Debug"}
  332. configuration "Release"
  333. flags { "Optimize", "EnableSSE2", "NoMinimalRebuild", "FloatFast"}
  334. if not _OPTIONS["dynamic-runtime"] then
  335. flags { "StaticRuntime" }
  336. end
  337. configuration "Debug"
  338. defines {"_DEBUG=1"}
  339. flags { "Symbols" , "NoMinimalRebuild", "NoEditAndContinue" ,"FloatFast"}
  340. if not _OPTIONS["dynamic-runtime"] then
  341. flags { "StaticRuntime" }
  342. end
  343. if os.is("Linux") or os.is("macosx") then
  344. if os.is64bit() then
  345. platforms {"x64"}
  346. else
  347. platforms {"x32"}
  348. end
  349. else
  350. platforms {"x32","x64"}
  351. end
  352. configuration {"x32"}
  353. targetsuffix ("_" .. act)
  354. configuration "x64"
  355. targetsuffix ("_" .. act .. "_64" )
  356. configuration {"x64", "debug"}
  357. targetsuffix ("_" .. act .. "_x64_debug")
  358. configuration {"x64", "release"}
  359. targetsuffix ("_" .. act .. "_x64_release" )
  360. configuration {"x32", "debug"}
  361. targetsuffix ("_" .. act .. "_debug" )
  362. configuration{}
  363. postfix=""
  364. if _ACTION == "xcode4" then
  365. if _OPTIONS["ios"] then
  366. _OPTIONS["no-bullet3"] = "1"
  367. _OPTIONS["no-gtest"] = "1"
  368. postfix = "ios";
  369. xcodebuildsettings
  370. {
  371. 'INFOPLIST_FILE = "../../test/Bullet2/Info.plist"',
  372. 'CODE_SIGN_IDENTITY = "iPhone Developer"',
  373. "SDKROOT = iphoneos",
  374. 'ARCHS = "armv7"',
  375. 'TARGETED_DEVICE_FAMILY = "1,2"',
  376. 'VALID_ARCHS = "armv7"',
  377. }
  378. else
  379. xcodebuildsettings
  380. {
  381. 'ARCHS = "$(ARCHS_STANDARD_64_BIT)"',
  382. 'VALID_ARCHS = "x86_64"',
  383. -- 'SDKROOT = "macosx10.9"',
  384. }
  385. end
  386. end
  387. -- comment-out for now, URDF reader needs exceptions
  388. -- flags { "NoRTTI", "NoExceptions"}
  389. -- defines { "_HAS_EXCEPTIONS=0" }
  390. --printf ( _OPTIONS["targetdir"] )
  391. targetdir( _OPTIONS["targetdir"] or "../bin" )
  392. location("./" .. act .. postfix)
  393. if not _OPTIONS["python_include_dir"] then
  394. _OPTIONS["python_include_dir"] = default_python_include_dir
  395. end
  396. if not _OPTIONS["python_lib_dir"] then
  397. _OPTIONS["python_lib_dir"] = default_python_lib_dir
  398. end
  399. if os.is("Linux") then
  400. default_glfw_include_dir = "usr/local/include/GLFW"
  401. default_glfw_lib_dir = "/usr/local/lib/"
  402. default_glfw_lib_name = "glfw3"
  403. end
  404. if os.is("macosx") then
  405. default_glfw_include_dir = "/usr/local/Cellar/glfw/3.2.1/include"
  406. default_glfw_lib_dir = "/usr/local/Cellar/glfw/3.2.1/lib"
  407. default_glfw_lib_name = "glfw"
  408. end
  409. if os.is("Windows") then
  410. default_glfw_include_dir = "c:/glfw/include"
  411. default_glfw_lib_dir = "c:/glfw/lib"
  412. default_glfw_lib_name = "glfw3"
  413. end
  414. if not _OPTIONS["glfw_lib_dir"] then
  415. _OPTIONS["glfw_lib_dir"] = default_glfw_lib_dir
  416. end
  417. if not _OPTIONS["glfw_include_dir"] then
  418. _OPTIONS["glfw_include_dir"] = default_glfw_include_dir
  419. end
  420. if not _OPTIONS["glfw_lib_name"] then
  421. _OPTIONS["glfw_lib_name"] = default_glfw_lib_name
  422. end
  423. newoption
  424. {
  425. trigger = "glfw_include_dir",
  426. value = default_glfw_include_dir,
  427. description = "GLFW 3.x include directory"
  428. }
  429. newoption
  430. {
  431. trigger = "glfw_lib_name",
  432. value = default_glfw_lib_name,
  433. description = "GLFW 3.x library name (glfw, glfw3)"
  434. }
  435. newoption
  436. {
  437. trigger = "glfw_lib_dir",
  438. value = default_glfw_lib_dir,
  439. description = "(optional) GLFW 3.x library directory "
  440. }
  441. newoption
  442. {
  443. trigger = "enable_glfw",
  444. value = false,
  445. description = "(optional) use GLFW 3.x library"
  446. }
  447. if _OPTIONS["enable_glfw"] then
  448. defines {"B3_USE_GLFW"}
  449. function initOpenGL()
  450. includedirs {
  451. projectRootDir .. "examples/ThirdPartyLibs/glad"
  452. }
  453. includedirs {
  454. _OPTIONS["glfw_include_dir"],
  455. }
  456. libdirs {
  457. _OPTIONS["glfw_lib_dir"]
  458. }
  459. links { _OPTIONS["glfw_lib_name"]}
  460. files { projectRootDir .. "examples/ThirdPartyLibs/glad/glad.c" }
  461. end
  462. function findOpenGL3()
  463. return true
  464. end
  465. function initGlew()
  466. end
  467. function initX11()
  468. links {"X11", "dl","pthread"}
  469. end
  470. else
  471. dofile ("findOpenGLGlewGlut.lua")
  472. if (not findOpenGL3()) then
  473. defines {"NO_OPENGL3"}
  474. end
  475. end
  476. dofile ("findOpenCL.lua")
  477. dofile ("findDirectX11.lua")
  478. language "C++"
  479. if _OPTIONS["audio"] then
  480. include "../examples/TinyAudio"
  481. end
  482. if _OPTIONS["serial"] then
  483. include "../examples/ThirdPartyLibs/serial"
  484. end
  485. if not _OPTIONS["no-demos"] then
  486. include "../examples/ExampleBrowser"
  487. include "../examples/RobotSimulator"
  488. include "../examples/OpenGLWindow"
  489. include "../examples/ThirdPartyLibs/Gwen"
  490. include "../examples/HelloWorld"
  491. include "../examples/SharedMemory"
  492. include "../examples/ThirdPartyLibs/BussIK"
  493. if _OPTIONS["lua"] then
  494. include "../examples/ThirdPartyLibs/lua-5.2.3"
  495. end
  496. if _OPTIONS["enable_pybullet"] then
  497. include "../examples/pybullet"
  498. end
  499. include "../examples/SimpleOpenGL3"
  500. if _OPTIONS["standalone-examples"] then
  501. include "../examples/TinyRenderer"
  502. include "../examples/BasicDemo"
  503. include "../examples/InverseDynamics"
  504. include "../examples/ExtendedTutorials"
  505. include "../examples/MultiThreading"
  506. end
  507. if not _OPTIONS["no-test"] then
  508. include "../test/SharedMemory"
  509. end
  510. end
  511. if _OPTIONS["midi"] then
  512. include "../examples/ThirdPartyLibs/midi"
  513. end
  514. if not _OPTIONS["no-clsocket"] then
  515. defines {"BT_ENABLE_CLSOCKET"}
  516. include "../examples/ThirdPartyLibs/clsocket"
  517. include "../test/clsocket"
  518. end
  519. if not _OPTIONS["no-enet"] then
  520. defines {"BT_ENABLE_ENET"}
  521. include "../examples/ThirdPartyLibs/enet"
  522. include "../test/enet/nat_punchthrough/client"
  523. include "../test/enet/nat_punchthrough/server"
  524. include "../test/enet/chat/client"
  525. include "../test/enet/chat/server"
  526. end
  527. if _OPTIONS["no-bullet3"] then
  528. print "--no-bullet3 implies --no-demos"
  529. _OPTIONS["no-demos"] = "1"
  530. else
  531. include "../src/Bullet3Common"
  532. include "../src/Bullet3Geometry"
  533. include "../src/Bullet3Collision"
  534. include "../src/Bullet3Dynamics"
  535. include "../src/Bullet3OpenCL"
  536. include "../src/Bullet3Serialize/Bullet2FileLoader"
  537. end
  538. if _OPTIONS["no-extras"] then
  539. print "--no-extras implies --no-demos"
  540. _OPTIONS["no-demos"] = "1"
  541. else
  542. include "../Extras"
  543. end
  544. if not _OPTIONS["no-test"] then
  545. if _OPTIONS["test-bullet2"] then
  546. include "../test/Bullet2"
  547. end
  548. if not _OPTIONS["no-gtest"] then
  549. include "../test/gtest-1.7.0"
  550. -- include "../test/hello_gtest"
  551. include "../test/collision"
  552. include "../test/BulletDynamics/pendulum"
  553. if not _OPTIONS["no-bullet3"] then
  554. if not _OPTIONS["no-extras"] then
  555. include "../test/InverseDynamics"
  556. end
  557. include "../test/TestBullet3OpenCL"
  558. end
  559. if not _OPTIONS["no-demos"] then
  560. -- Gwen is only used for demos
  561. include "../test/GwenOpenGLTest"
  562. end
  563. end
  564. end
  565. include "../src/BulletInverseDynamics"
  566. include "../src/BulletSoftBody"
  567. include "../src/BulletDynamics"
  568. include "../src/BulletCollision"
  569. include "../src/LinearMath"
  570. if _OPTIONS["enable_physx"] then
  571. include "../src/physx"
  572. end