xmake.lua 4.8 KB

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