xmake.lua 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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_deps("cmake")
  9. on_load("windows", function (package)
  10. if package:config("shared") then
  11. package:add("defines", "MESHOPTIMIZER_API=__declspec(dllimport)")
  12. end
  13. end)
  14. on_install("windows", "macosx", "linux", function (package)
  15. local configs = {}
  16. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  17. table.insert(configs, "-DMESHOPT_BUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  18. import("package.tools.cmake").install(package, configs)
  19. end)
  20. on_test(function (package)
  21. assert(package:check_cxxsnippets({test = [[
  22. #include <vector>
  23. struct Vertex
  24. {
  25. float px, py, pz;
  26. float nx, ny, nz;
  27. float tx, ty;
  28. };
  29. void test() {
  30. size_t total_indices = 0;
  31. std::vector<Vertex> vertices(total_indices);
  32. std::vector<unsigned int> remap(total_indices);
  33. size_t total_vertices = meshopt_generateVertexRemap(&remap[0], NULL, total_indices, &vertices[0], total_indices, sizeof(Vertex));
  34. }
  35. ]]}, {configs = {language = "cxx11"}, includes = "meshoptimizer.h"}))
  36. end)