xmake.lua 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package("tinyobjloader")
  2. set_homepage("https://github.com/tinyobjloader/tinyobjloader")
  3. set_description("Tiny but powerful single file wavefront obj loader")
  4. set_license("MIT")
  5. add_urls("https://github.com/tinyobjloader/tinyobjloader/archive/v$(version).tar.gz",
  6. "https://github.com/tinyobjloader/tinyobjloader.git")
  7. add_versions("1.0.7", "b9d08b675ba54b9cb00ffc99eaba7616d0f7e6f6b8947a7e118474e97d942129")
  8. add_configs("double", {description = "Use double precision floating numbers.", default = false, type = "boolean"})
  9. if is_plat("windows") then
  10. add_configs("shared", {description = "Build shared library.", default = true, type = "boolean", readonly = true})
  11. end
  12. on_load(function (package)
  13. if package:config("double") then
  14. package:add("defines", "TINYOBJLOADER_USE_DOUBLE")
  15. end
  16. end)
  17. on_install("macosx", "linux", "windows", "mingw", "android", "iphoneos", function (package)
  18. io.writefile("xmake.lua", string.format([[
  19. add_rules("mode.debug", "mode.release")
  20. target("tinyobjloader")
  21. set_kind("$(kind)")
  22. %s
  23. add_files("tiny_obj_loader.cc")
  24. add_headerfiles("tiny_obj_loader.h")
  25. ]], package:config("double") and "add_defines(\"TINYOBJLOADER_USE_DOUBLE\")" or ""))
  26. import("package.tools.xmake").install(package)
  27. end)
  28. on_test(function (package)
  29. assert(package:check_cxxsnippets({test = [[
  30. #include <vector>
  31. void test() {
  32. tinyobj::attrib_t attrib;
  33. std::vector<tinyobj::shape_t> shapes;
  34. std::vector<tinyobj::material_t> materials;
  35. }
  36. ]]}, {configs = {languages = "c++11"}, includes = "tiny_obj_loader.h"}))
  37. end)