xmake.lua 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. if is_plat("windows") then
  15. add_syslinks("comdlg32")
  16. elseif is_plat("linux") then
  17. add_syslinks("pthread")
  18. end
  19. add_deps("cmake", "eigen")
  20. on_load("macosx", "linux", "windows", function (package)
  21. if not package:config("header_only") then
  22. raise("Non-header-only version is not supported yet!")
  23. end
  24. if package:config("cgal") then
  25. package:add("deps", "cgal")
  26. end
  27. if package:config("imgui") then
  28. package:add("deps", "imgui", {configs = {glfw_opengl3 = true}})
  29. end
  30. end)
  31. on_install("macosx", "linux", "windows", function (package)
  32. if package:config("imgui") then
  33. local igl_imgui_dir = package:resourcefile("libigl_imgui")
  34. os.cp(path.join(igl_imgui_dir, "imgui_fonts_droid_sans.h"), package:installdir("include"))
  35. end
  36. if package:config("header_only") then
  37. os.mv("include/igl", package:installdir("include"))
  38. return
  39. end
  40. local configs = {"-DLIBIGL_BUILD_TESTS=OFF", "-DLIBIGL_BUILD_TUTORIALS=OFF", "-DLIBIGL_SKIP_DOWNLOAD=ON"}
  41. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  42. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or"OFF"))
  43. if not package:config("shared") then
  44. table.insert(configs, "-DLIBIGL_USE_STATIC_LIBRARY=ON")
  45. end
  46. if package:is_plat("windows") then
  47. table.insert(configs, "-DIGL_STATIC_RUNTIME=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
  48. end
  49. import("package.tools.cmake").install(package, configs)
  50. end)
  51. on_test(function (package)
  52. assert(package:check_cxxsnippets({test = [[
  53. void test() {
  54. Eigen::MatrixXd V(4,2);
  55. V<<0,0,
  56. 1,0,
  57. 1,1,
  58. 0,1;
  59. Eigen::MatrixXi F(2,3);
  60. F<<0,1,2,
  61. 0,2,3;
  62. Eigen::SparseMatrix<double> L;
  63. igl::cotmatrix(V,F,L);
  64. }
  65. ]]}, {configs = {languages = "c++14"}, includes = {"igl/cotmatrix.h", "Eigen/Dense", "Eigen/Sparse"}}))
  66. end)