xmake.lua 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package("libwebp")
  2. set_homepage("https://chromium.googlesource.com/webm/libwebp/")
  3. set_description("Library to encode and decode images in WebP format.")
  4. set_license("BSD-3-Clause")
  5. add_urls("https://github.com/webmproject/libwebp/archive/$(version).tar.gz",
  6. "https://github.com/webmproject/libwebp.git")
  7. add_versions("v1.1.0", "424faab60a14cb92c2a062733b6977b4cc1e875a6398887c5911b3a1a6c56c51")
  8. add_versions("v1.2.2", "51e9297aadb7d9eb99129fe0050f53a11fcce38a0848fb2b0389e385ad93695e")
  9. add_configs("anim_utils", {description = "Build animation utilities.", default = false, type = "boolean"})
  10. add_configs("cwebp", {description = "Build the cwebp command line tool.", default = false, type = "boolean"})
  11. add_configs("dwebp", {description = "Build the dwebp command line tool.", default = false, type = "boolean"})
  12. add_configs("gif2webp", {description = "Build the gif2webp conversion tool.", default = false, type = "boolean"})
  13. add_configs("img2webp", {description = "Build the img2webp animation tool.", default = false, type = "boolean"})
  14. add_configs("vwebp", {description = "Build the vwebp viewer tool.", default = false, type = "boolean"})
  15. add_configs("webpinfo", {description = "Build the webpinfo command line tool.", default = false, type = "boolean"})
  16. add_configs("libwebpmux", {description = "Build the libwebpmux library.", default = false, type = "boolean"})
  17. add_configs("webpmux", {description = "Build the webpmux command line tool.", default = false, type = "boolean"})
  18. add_configs("sharpyuv", {description = "Build the sharpyuv library.", default = false, type = "boolean"})
  19. add_configs("extras", {description = "Build extras.", default = false, type = "boolean"})
  20. add_deps("cmake")
  21. add_deps("libpng", "libjpeg", "libtiff", "giflib")
  22. if is_plat("linux", "bsd") then
  23. add_syslinks("pthread")
  24. end
  25. if is_plat("macosx") then
  26. add_extsources("brew::webp")
  27. elseif is_plat("linux") then
  28. add_extsources("apt::libwebp-dev", "pacman::libwebp")
  29. end
  30. on_install("linux", "macosx", "windows", "mingw", "bsd", function (package)
  31. local configs = {}
  32. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  33. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  34. for name, enabled in pairs(package:configs()) do
  35. if not package:extraconf("configs", name, "builtin") then
  36. table.insert(configs, "-DWEBP_BUILD_" .. name:upper() .. "=" .. (enabled and "ON" or "OFF"))
  37. end
  38. end
  39. local cxflags
  40. if package:is_plat("windows") and package:config("shared") then
  41. cxflags = "-DWEBP_EXTERN=__declspec(dllexport)"
  42. end
  43. import("package.tools.cmake").install(package, configs, {cxflags = cxflags})
  44. end)
  45. on_test(function (package)
  46. assert(package:has_cfuncs("WebPGetEncoderVersion", {includes = "webp/encode.h"}))
  47. end)