xmake.lua 4.6 KB

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