xmake.lua 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package("dartsim")
  2. set_homepage("https://dartsim.github.io/")
  3. set_description("Dynamic Animation and Robotics Toolkit")
  4. set_license("BSD-2-Clause")
  5. add_urls("https://github.com/dartsim/dart/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/dartsim/dart.git")
  7. add_versions("v6.13.0", "4da3ff8cee056252a558b05625a5ff29b21e71f2995e6d7f789abbf6261895f7")
  8. add_configs("dartpy", {description = "Build dartpy interface.", default = false, type = "boolean"})
  9. local configdeps = {bullet3 = "Bullet",
  10. freeglut = "GLUT",
  11. nlopt = "NLOPT",
  12. ode = "ODE",
  13. openscenegraph = "OpenSceneGraph",
  14. tinyxml2 = "tinyxml2",
  15. urdfdom = "urdfdom",
  16. spdlog = "spdlog"}
  17. for config, dep in pairs(configdeps) do
  18. add_configs(config, {description = "Enable " .. config .. " support.", default = false, type = "boolean"})
  19. end
  20. if is_plat("windows") then
  21. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  22. add_cxxflags("/permissive-")
  23. add_syslinks("user32")
  24. end
  25. add_deps("cmake")
  26. add_deps("assimp", "libccd", "eigen", "fcl", "octomap", "fmt")
  27. on_load("windows|x64", "linux", "macosx", function (package)
  28. for config, dep in pairs(configdeps) do
  29. if package:config(config) then
  30. package:add("deps", config)
  31. end
  32. end
  33. end)
  34. on_install("windows|x64", "linux", "macosx", function (package)
  35. io.replace("CMakeLists.txt", "/GL", "", {plain = true})
  36. io.replace("CMakeLists.txt", "if(TARGET dart)", "if(FALSE)", {plain = true})
  37. io.replace("dart/CMakeLists.txt", "/LTCG", "", {plain = true})
  38. io.replace("python/CMakeLists.txt", "add_subdirectory(tests)", "", {plain = true})
  39. io.replace("python/CMakeLists.txt", "add_subdirectory(examples)", "", {plain = true})
  40. io.replace("python/CMakeLists.txt", "add_subdirectory(tutorials)", "", {plain = true})
  41. io.replace("cmake/DARTFindDependencies.cmake", "dart_check_required_package(assimp \"assimp\")", "dart_check_required_package(assimp \"assimp\")\nfind_package(ZLIB)\ntarget_link_libraries(assimp INTERFACE ZLIB::ZLIB)", {plain = true})
  42. io.replace("cmake/DARTFindDependencies.cmake", "dart_check_required_package(fcl \"fcl\")", "dart_check_required_package(fcl \"fcl\")\ntarget_link_libraries(fcl INTERFACE ccd)", {plain = true})
  43. io.replace("cmake/DARTFindDependencies.cmake", "check_cxx_source_compiles%(.-\".-\".-(ASSIMP.-DEFINED)%)", "set(%1 1)")
  44. local configs = {
  45. "-DDART_SKIP_lz4=ON",
  46. "-DDART_SKIP_flann=ON",
  47. "-DDART_SKIP_IPOPT=ON",
  48. "-DDART_SKIP_pagmo=ON",
  49. "-DDART_SKIP_DOXYGEN=ON",
  50. "-DDART_TREAT_WARNINGS_AS_ERRORS=OFF",
  51. }
  52. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  53. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  54. for config, dep in pairs(configdeps) do
  55. table.insert(configs, "-DDART_SKIP_" .. dep .. "=" .. (package:config(config) and "OFF" or "ON"))
  56. end
  57. if package:is_plat("windows") then
  58. table.insert(configs, "-DDART_RUNTIME_LIBRARY=" .. (package:config("vs_runtime"):startswith("MT") and "/MT" or "/MD"))
  59. end
  60. table.insert(configs, "-DDART_BUILD_DARTPY=" .. (package:config("dartpy") and "ON" or "OFF"))
  61. table.insert(configs, "-DDART_BUILD_GUI_OSG=" .. (package:config("openscenegraph") and "ON" or "OFF"))
  62. import("package.tools.cmake").install(package, configs)
  63. end)
  64. on_test(function (package)
  65. assert(package:check_cxxsnippets({test = [[
  66. #include <dart/dart.hpp>
  67. void test() {
  68. dart::simulation::WorldPtr world = dart::simulation::World::create();
  69. }
  70. ]]}, {configs = {languages = "c++17"}}))
  71. end)