xmake.lua 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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/$(version).tar.gz")
  6. add_urls("https://github.com/tinyobjloader/tinyobjloader.git")
  7. add_versions("v1.0.7", "b9d08b675ba54b9cb00ffc99eaba7616d0f7e6f6b8947a7e118474e97d942129")
  8. add_versions("v2.0.0rc10", "e1bc2e5547b562d33ca4a90b581717984a70d58113d83208dbc97c82e137b9fe")
  9. add_configs("double", {description = "Use double precision floating numbers.", default = false, type = "boolean"})
  10. if is_plat("windows") then
  11. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  12. end
  13. on_load(function (package)
  14. if package:config("double") then
  15. package:add("defines", "TINYOBJLOADER_USE_DOUBLE")
  16. end
  17. end)
  18. on_install("macosx", "linux", "windows", "mingw", "android", "iphoneos", function (package)
  19. io.writefile("xmake.lua", string.format([[
  20. add_rules("mode.debug", "mode.release")
  21. add_rules("utils.install.cmake_importfiles")
  22. target("tinyobjloader")
  23. set_kind("$(kind)")
  24. %s
  25. add_files("tiny_obj_loader.cc")
  26. add_headerfiles("tiny_obj_loader.h")
  27. ]], package:config("double") and "add_defines(\"TINYOBJLOADER_USE_DOUBLE\")" or ""))
  28. import("package.tools.xmake").install(package)
  29. end)
  30. on_test(function (package)
  31. assert(package:check_cxxsnippets({test = [[
  32. #include <vector>
  33. void test() {
  34. tinyobj::attrib_t attrib;
  35. std::vector<tinyobj::shape_t> shapes;
  36. std::vector<tinyobj::material_t> materials;
  37. }
  38. ]]}, {configs = {languages = "c++11"}, includes = "tiny_obj_loader.h"}))
  39. end)