xmake.lua 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package("meshoptimizer")
  2. set_homepage("https://github.com/zeux/meshoptimizer")
  3. set_description("Mesh optimization library that makes meshes smaller and faster to render")
  4. set_license("MIT")
  5. add_urls("https://github.com/zeux/meshoptimizer/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/zeux/meshoptimizer.git")
  7. add_versions("v0.18", "f5bc07d7322e6292fe0afce03462b5c394d111386236f926fdc44d2aff3b854b")
  8. add_versions("v0.20", "cf1077a83958bed3d8da28a841ca53a6a42d871e49023edce64e37002a0f5a48")
  9. add_versions("v0.21", "050a5438e4644833ff69f35110fcf4e37038a89c5fdc8aed45d8cd848ecb3a20")
  10. add_deps("cmake")
  11. on_load("windows", function (package)
  12. if package:config("shared") then
  13. package:add("defines", "MESHOPTIMIZER_API=__declspec(dllimport)")
  14. end
  15. end)
  16. on_install("windows", "macosx", "linux", function (package)
  17. local configs = {}
  18. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  19. table.insert(configs, "-DMESHOPT_BUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  20. import("package.tools.cmake").install(package, configs)
  21. end)
  22. on_test(function (package)
  23. assert(package:check_cxxsnippets({test = [[
  24. #include <vector>
  25. struct Vertex
  26. {
  27. float px, py, pz;
  28. float nx, ny, nz;
  29. float tx, ty;
  30. };
  31. void test() {
  32. size_t total_indices = 0;
  33. std::vector<Vertex> vertices(total_indices);
  34. std::vector<unsigned int> remap(total_indices);
  35. size_t total_vertices = meshopt_generateVertexRemap(&remap[0], NULL, total_indices, &vertices[0], total_indices, sizeof(Vertex));
  36. }
  37. ]]}, {configs = {language = "cxx11"}, includes = "meshoptimizer.h"}))
  38. end)