xmake.lua 4.9 KB

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