xmake.lua 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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_syslinks("comdlg32")
  18. elseif is_plat("linux") then
  19. add_syslinks("pthread")
  20. end
  21. add_deps("cmake", "eigen")
  22. on_load("macosx", "linux", "windows", "mingw", function (package)
  23. if not package:config("header_only") then
  24. raise("Non-header-only version is not supported yet!")
  25. end
  26. if package:config("cgal") then
  27. package:add("deps", "cgal")
  28. end
  29. if package:config("imgui") then
  30. package:add("deps", "imgui", {configs = {glfw_opengl3 = true}})
  31. package:add("deps", "glad")
  32. end
  33. if package:config("embree") then
  34. package:add("deps", "embree")
  35. end
  36. end)
  37. on_install("macosx", "linux", "windows", "mingw", function (package)
  38. if package:config("imgui") then
  39. local igl_imgui_dir = package:resourcefile("libigl_imgui")
  40. os.cp(path.join(igl_imgui_dir, "imgui_fonts_droid_sans.h"), package:installdir("include"))
  41. end
  42. if package:config("header_only") then
  43. os.cp("include/igl", package:installdir("include"))
  44. return
  45. end
  46. local configs = {"-DLIBIGL_BUILD_TESTS=OFF", "-DLIBIGL_BUILD_TUTORIALS=OFF", "-DLIBIGL_SKIP_DOWNLOAD=ON"}
  47. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  48. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or"OFF"))
  49. if not package:config("shared") then
  50. table.insert(configs, "-DLIBIGL_USE_STATIC_LIBRARY=ON")
  51. end
  52. if package:is_plat("windows") then
  53. table.insert(configs, "-DIGL_STATIC_RUNTIME=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
  54. end
  55. import("package.tools.cmake").install(package, configs)
  56. end)
  57. on_test(function (package)
  58. assert(package:check_cxxsnippets({test = [[
  59. void test() {
  60. Eigen::MatrixXd V(4,2);
  61. V<<0,0,
  62. 1,0,
  63. 1,1,
  64. 0,1;
  65. Eigen::MatrixXi F(2,3);
  66. F<<0,1,2,
  67. 0,2,3;
  68. Eigen::SparseMatrix<double> L;
  69. igl::cotmatrix(V,F,L);
  70. }
  71. ]]}, {configs = {languages = "c++14"}, includes = {"igl/cotmatrix.h", "Eigen/Dense", "Eigen/Sparse"}}))
  72. if package:config("imgui") then
  73. assert(package:check_cxxsnippets({test = [[
  74. void test() {
  75. Eigen::MatrixXd V;
  76. Eigen::MatrixXi F;
  77. igl::opengl::glfw::Viewer viewer;
  78. viewer.data().set_mesh(V, F);
  79. viewer.launch();
  80. }
  81. ]]}, {configs = {languages = "c++14"}, includes = {"igl/opengl/glfw/Viewer.h", "Eigen/Dense", "Eigen/Sparse"}}))
  82. end
  83. if package:config("embree") then
  84. assert(package:check_cxxsnippets({test = [[
  85. void test() {
  86. Eigen::MatrixXf V;
  87. Eigen::MatrixXi F;
  88. igl::embree::EmbreeIntersector ei;
  89. ei.init(V,F);
  90. igl::Hit hit{};
  91. Eigen::Vector3f look_from{1.0f, 1.0f, 1.0f}, dir{1.0f, 1.0f, 1.0f};
  92. bool is_hit = ei.intersectRay(look_from, dir, hit);
  93. }
  94. ]]}, {configs = {languages = "c++14"}, includes = {"igl/embree/EmbreeIntersector.h", "igl/Hit.h", "Eigen/Dense", "Eigen/Sparse"}}))
  95. end
  96. end)