xmake.lua 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. package("manifold")
  2. set_homepage("https://github.com/elalish/manifold")
  3. set_description("A Geometry library for topological robustness")
  4. set_license("Apache-2.0")
  5. set_urls("https://github.com/elalish/manifold/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/elalish/manifold.git")
  7. add_versions("v3.2.1", "c2fddb0f4b2289caff660b29677883f0324415a9901f8f2aed4c83851f994c13")
  8. add_configs("parallel", { description = "Enable parallel processing", default = false, type = "boolean"})
  9. add_configs("cross_section", { description = "Enable 2d simple operation", default = false, type = "boolean" })
  10. add_configs("exporter", { description = "Enable exporting models", default = false, type = "boolean" })
  11. add_configs("tracy", { description = "Enable profiling", default = false, type = "boolean" })
  12. add_configs("cbind", { description = "Enable c binding", default = true, type = "boolean" })
  13. add_deps("cmake")
  14. if is_plat("linux", "bsd") then
  15. add_syslinks("m")
  16. end
  17. if on_check then
  18. on_check("android", function (package)
  19. local ndk = package:toolchain("ndk")
  20. local ndk_sdkver = ndk:config("ndk_sdkver")
  21. assert(ndk_sdkver and tonumber(ndk_sdkver) >= 26, "package(manifold): need ndk api level >= 26 for android")
  22. end)
  23. end
  24. on_load(function(package)
  25. if package:config("exporter") then
  26. package:add("deps", "assimp")
  27. end
  28. if package:config("parallel") then
  29. package:add("deps", "tbb")
  30. end
  31. if package:config("cross_section") then
  32. package:add("deps", "clipper2")
  33. end
  34. end)
  35. on_install(function (package)
  36. if package:is_plat("wasm") then
  37. io.replace("CMakeLists.txt", "return()", "", {plain = true})
  38. end
  39. io.replace("src/quickhull.cpp", [[#include <limits>]], [[#include <limits>
  40. #include <unordered_map>
  41. #include <cstddef>]], {plain = true})
  42. io.replace("src/smoothing.cpp", [[#include "parallel.h"]], [[#include "parallel.h"
  43. #include <unordered_map>]], {plain = true})
  44. io.replace("src/subdivision.cpp", [[#include "parallel.h"]], [[#include "parallel.h"
  45. #include <unordered_map>]], {plain = true})
  46. io.replace("src/disjoint_sets.h", "for (size_t", "for (std::size_t", {plain = true})
  47. local configs = {
  48. "-DMANIFOLD_STRICT=OFF",
  49. "-DMANIFOLD_TEST=OFF",
  50. "-DMANIFOLD_DOWNLOADS=OFF",
  51. "-DMANIFOLD_JSBIND=OFF",
  52. "-DMANIFOLD_PYBIND=OFF",
  53. }
  54. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  55. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  56. table.insert(configs, "-DMANIFOLD_CBIND=" .. (package:config("cbind") and "ON" or "OFF"))
  57. table.insert(configs, "-DMANIFOLD_PAR=" .. (package:config("parallel") and "ON" or "OFF"))
  58. table.insert(configs, "-DMANIFOLD_CROSS_SECTION=" .. (package:config("cross_section") and "ON" or "OFF"))
  59. table.insert(configs, "-DMANIFOLD_EXPORT=" .. (package:config("exporter") and "ON" or "OFF"))
  60. table.insert(configs, "-DTRACY_ENABLE=" .. (package:config("tracy") and "ON" or "OFF"))
  61. table.insert(configs, "-DMANIFOLD_DEBUG=" .. (package:is_debug() and "ON" or "OFF"))
  62. table.insert(configs, "-DMANIFOLD_ASSERT=" .. (package:is_debug() and "ON" or "OFF"))
  63. import("package.tools.cmake").install(package, configs)
  64. end)
  65. on_test(function(package)
  66. assert(package:check_cxxsnippets({test = [[
  67. #include <manifold/manifold.h>
  68. void test() {
  69. manifold::Manifold cube = manifold::Manifold::Cube({1, 1, 1});
  70. (void)cube;
  71. }
  72. ]]}, {configs = {languages = "c++17"}}))
  73. end)