xmake.lua 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package("ptex")
  2. set_homepage("http://ptex.us/")
  3. set_description("Per-Face Texture Mapping for Production Rendering")
  4. set_license("BSD-3-Clause")
  5. add_urls("https://github.com/wdas/ptex/archive/$(version).tar.gz",
  6. "https://github.com/wdas/ptex.git")
  7. add_versions("v2.3.2", "30aeb85b965ca542a8945b75285cd67d8e207d23dbb57fcfeaab587bb443402b")
  8. add_versions("v2.4.1", "664253b84121251fee2961977fe7cf336b71cd846dc235cd0f4e54a0c566084e")
  9. add_versions("v2.4.2", "c8235fb30c921cfb10848f4ea04d5b662ba46886c5e32ad5137c5086f3979ee1")
  10. add_deps("zlib")
  11. if is_plat("linux") then
  12. add_syslinks("pthread")
  13. end
  14. on_load("windows", "mingw@windows", function (package)
  15. if not package:config("shared") then
  16. package:add("defines", "PTEX_STATIC")
  17. end
  18. end)
  19. on_install("windows", "linux", "macosx", function (package)
  20. io.replace("src/ptex/PtexPlatform.h", "sys/types.h", "unistd.h", {plain = true})
  21. io.writefile("xmake.lua", format([[
  22. add_rules("mode.debug", "mode.release")
  23. set_configvar("PTEX_MAJOR_VERSION", "%s")
  24. set_configvar("PTEX_MINOR_VERSION", "%s")
  25. add_requires("zlib")
  26. target("ptex")
  27. set_kind("$(kind)")
  28. add_packages("zlib")
  29. add_files("src/ptex/*.cpp")
  30. add_includedirs("src/ptex", {public = true})
  31. add_headerfiles("src/ptex/(*.h)")
  32. set_configdir("src/ptex")
  33. add_configfiles("src/ptex/PtexVersion.h.in", {pattern = "@(.-)@"})
  34. if is_plat("macosx") or is_plat("linux") then
  35. add_syslinks("pthread")
  36. add_cxxflags("-fvisibility=default")
  37. end
  38. if get_config("kind") == "static" then
  39. add_defines("PTEX_STATIC", {public = true})
  40. else
  41. add_defines("PTEX_EXPORTS")
  42. end
  43. target("ptxinfo")
  44. set_kind("binary")
  45. add_deps("ptex")
  46. add_packages("zlib")
  47. add_files("src/utils/ptxinfo.cpp")
  48. ]], package:version():major(), package:version():minor()))
  49. local configs = {}
  50. if package:config("shared") then
  51. configs.kind = "shared"
  52. elseif package:is_plat("linux") and package:config("pic") ~= false then
  53. configs.cxflags = "-fPIC"
  54. end
  55. import("package.tools.xmake").install(package, configs)
  56. end)
  57. on_test(function (package)
  58. assert(package:check_cxxsnippets({test = [[
  59. void test() {
  60. Ptex::String error;
  61. PtexPtr<PtexCache> c(PtexCache::create(0,0));
  62. }
  63. ]]}, {includes = "Ptexture.h"}))
  64. end)