xmake.lua 2.0 KB

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