xmake.lua 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. package("libigl")
  2. set_homepage("https://libigl.github.io/")
  3. set_description("Simple C++ geometry processing library.")
  4. set_license("MPL-2.0")
  5. add_urls("https://github.com/libigl/libigl/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/libigl/libigl.git")
  7. add_versions("v2.2.0", "b336e548d718536956e2d6958a0624bc76d50be99039454072ecdc5cf1b2ede5")
  8. add_versions("v2.3.0", "9d6de3bdb9c1cfc61a0a0616fd96d14ef8465995600328c196fa672ee4579b70")
  9. add_versions("v2.4.0", "f3f53ee6f1e9a6c529378c6b0439cd2cfc0e30b2178b483fe6bea169ce6deb22")
  10. add_versions("v2.5.0", "1d9d8c3a3a6a269cf22612bbe24d7fd1c5f84838231d299d712969ad294f945f")
  11. add_resources("2.x", "libigl_imgui", "https://github.com/libigl/libigl-imgui.git", "7e1053e750b0f4c129b046f4e455243cb7f804f3")
  12. add_configs("header_only", {description = "Use header only version.", default = true, type = "boolean"})
  13. add_configs("cgal", {description = "Use CGAL library.", default = false, type = "boolean"})
  14. add_configs("imgui", {description = "Use imgui with libigl.", default = false, type = "boolean"})
  15. add_configs("embree", {description = "Use embree library.", default = false, type = "boolean"})
  16. if is_plat("windows") then
  17. add_defines("NOMINMAX")
  18. add_syslinks("comdlg32")
  19. elseif is_plat("linux") then
  20. add_syslinks("pthread")
  21. end
  22. add_deps("cmake", "eigen")
  23. on_load("macosx", "linux", "windows", "mingw", function (package)
  24. if package:config("header_only") then
  25. package:set("kind", "library", {headeronly = true})
  26. else
  27. raise("Non-header-only version is not supported yet!")
  28. end
  29. if package:config("cgal") then
  30. package:add("deps", "cgal")
  31. end
  32. if package:config("imgui") then
  33. package:add("deps", "imgui", {configs = {glfw_opengl3 = true}})
  34. package:add("deps", "glad")
  35. end
  36. if package:config("embree") then
  37. package:add("deps", "embree")
  38. end
  39. end)
  40. on_install("macosx", "linux", "windows", "mingw", function (package)
  41. if package:config("imgui") then
  42. local igl_imgui_dir = package:resourcefile("libigl_imgui")
  43. os.cp(path.join(igl_imgui_dir, "imgui_fonts_droid_sans.h"), package:installdir("include"))
  44. end
  45. if package:config("header_only") then
  46. os.cp("include/igl", package:installdir("include"))
  47. return
  48. end
  49. local configs = {"-DLIBIGL_BUILD_TESTS=OFF", "-DLIBIGL_BUILD_TUTORIALS=OFF", "-DLIBIGL_SKIP_DOWNLOAD=ON"}
  50. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  51. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or"OFF"))
  52. if not package:config("shared") then
  53. table.insert(configs, "-DLIBIGL_USE_STATIC_LIBRARY=ON")
  54. end
  55. if package:is_plat("windows") then
  56. table.insert(configs, "-DIGL_STATIC_RUNTIME=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
  57. end
  58. import("package.tools.cmake").install(package, configs)
  59. end)
  60. on_test(function (package)
  61. assert(package:check_cxxsnippets({test = [[
  62. void test() {
  63. Eigen::MatrixXd V(4,2);
  64. V<<0,0,
  65. 1,0,
  66. 1,1,
  67. 0,1;
  68. Eigen::MatrixXi F(2,3);
  69. F<<0,1,2,
  70. 0,2,3;
  71. Eigen::SparseMatrix<double> L;
  72. igl::cotmatrix(V,F,L);
  73. }
  74. ]]}, {configs = {languages = "c++14"}, includes = {"igl/cotmatrix.h", "Eigen/Dense", "Eigen/Sparse"}}))
  75. if package:config("imgui") then
  76. assert(package:check_cxxsnippets({test = [[
  77. void test() {
  78. Eigen::MatrixXd V;
  79. Eigen::MatrixXi F;
  80. igl::opengl::glfw::Viewer viewer;
  81. viewer.data().set_mesh(V, F);
  82. viewer.launch();
  83. }
  84. ]]}, {configs = {languages = "c++14"}, includes = {"igl/opengl/glfw/Viewer.h", "Eigen/Dense", "Eigen/Sparse"}}))
  85. end
  86. if package:config("embree") then
  87. assert(package:check_cxxsnippets({test = [[
  88. void test() {
  89. Eigen::MatrixXf V;
  90. Eigen::MatrixXi F;
  91. igl::embree::EmbreeIntersector ei;
  92. ei.init(V,F);
  93. igl::Hit hit{};
  94. Eigen::Vector3f look_from{1.0f, 1.0f, 1.0f}, dir{1.0f, 1.0f, 1.0f};
  95. bool is_hit = ei.intersectRay(look_from, dir, hit);
  96. }
  97. ]]}, {configs = {languages = "c++14"}, includes = {"igl/embree/EmbreeIntersector.h", "igl/Hit.h", "Eigen/Dense", "Eigen/Sparse"}}))
  98. end
  99. end)