xmake.lua 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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/refs/tags/$(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_versions("v2.4.3", "435aa2ee1781ff24859bd282b7616bfaeb86ca10604b13d085ada8aa7602ad27")
  11. add_deps("zlib")
  12. if is_plat("linux") then
  13. add_syslinks("pthread")
  14. end
  15. on_load("windows", "mingw@windows", function (package)
  16. if not package:config("shared") then
  17. package:add("defines", "PTEX_STATIC")
  18. end
  19. end)
  20. on_install("windows", "linux", "macosx", function (package)
  21. io.replace("src/ptex/PtexPlatform.h", "sys/types.h", "unistd.h", {plain = true})
  22. io.writefile("xmake.lua", format([[
  23. add_rules("mode.debug", "mode.release")
  24. set_configvar("PTEX_MAJOR_VERSION", "%s")
  25. set_configvar("PTEX_MINOR_VERSION", "%s")
  26. add_requires("zlib")
  27. target("ptex")
  28. set_kind("$(kind)")
  29. add_packages("zlib")
  30. add_files("src/ptex/*.cpp")
  31. add_includedirs("src/ptex", {public = true})
  32. add_headerfiles("src/ptex/(*.h)")
  33. set_configdir("src/ptex")
  34. add_configfiles("src/ptex/PtexVersion.h.in", {pattern = "@(.-)@"})
  35. if is_plat("macosx") or is_plat("linux") then
  36. add_syslinks("pthread")
  37. add_cxxflags("-fvisibility=default")
  38. end
  39. if get_config("kind") == "static" then
  40. add_defines("PTEX_STATIC", {public = true})
  41. else
  42. add_defines("PTEX_EXPORTS")
  43. end
  44. target("ptxinfo")
  45. set_kind("binary")
  46. add_deps("ptex")
  47. add_packages("zlib")
  48. add_files("src/utils/ptxinfo.cpp")
  49. ]], package:version():major(), package:version():minor()))
  50. local configs = {}
  51. if package:config("shared") then
  52. configs.kind = "shared"
  53. elseif package:is_plat("linux") and package:config("pic") ~= false then
  54. configs.cxflags = "-fPIC"
  55. end
  56. import("package.tools.xmake").install(package, configs)
  57. end)
  58. on_test(function (package)
  59. assert(package:check_cxxsnippets({test = [[
  60. void test() {
  61. Ptex::String error;
  62. PtexPtr<PtexCache> c(PtexCache::create(0,0));
  63. }
  64. ]]}, {includes = "Ptexture.h"}))
  65. end)