xmake.lua 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. package("lcms")
  2. set_homepage("https://www.littlecms.com/")
  3. set_description("A free, open source, CMM engine. It provides fast transforms between ICC profiles.")
  4. set_license("MIT")
  5. add_urls("https://github.com/mm2/Little-CMS/archive/refs/tags/lcms$(version).tar.gz",
  6. "https://github.com/mm2/Little-CMS.git")
  7. add_versions("2.17", "6e6f6411db50e85ae8ff7777f01b2da0614aac13b7b9fcbea66dc56a1bc71418")
  8. add_patches("2.17", "https://github.com/mm2/Little-CMS/commit/1723db795a477de2b010db7a53b2d159ab94c3fa.diff",
  9. "5f47d872f0439ec340e6f59089abbd6ea579539f85a31634787dfbbd9c0bb8aa")
  10. add_deps("meson", "ninja")
  11. add_configs("jpeg", {description = "Use JPEG", default = false, type = "boolean"})
  12. add_configs("tiff", {description = "Use LibTiff", default = false, type = "boolean"})
  13. add_configs("utils", {description = "Build the utils", default = false, type = "boolean"})
  14. add_configs("fastfloat", {description = "Build and install the fast float plugin, use only if GPL 3.0 is acceptable", default = false, type = "boolean"})
  15. add_configs("threaded", {description = "Build and install the multi threaded plugin, use only if GPL 3.0 is acceptable", default = false, type = "boolean"})
  16. if is_plat("linux", "bsd") then
  17. add_syslinks("pthread", "m")
  18. elseif is_plat("wasm") then
  19. add_syslinks("pthread")
  20. add_ldflags("-s USE_PTHREADS=1")
  21. add_cxflags("-pthread")
  22. end
  23. on_load(function (package)
  24. if package:is_plat("windows") and package:config("shared") then
  25. package:add("defines", "CMS_DLL")
  26. end
  27. if package:config("jpeg") then
  28. package:add("deps", "libjpeg")
  29. end
  30. if package:config("tiff") then
  31. package:add("deps", "libtiff")
  32. end
  33. end)
  34. on_install(function (package)
  35. local configs = {}
  36. if package:is_plat("wasm") and package:config("shared") then
  37. table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
  38. table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes"))
  39. if package:config("jpeg") then
  40. table.insert(configs, "--with-jpeg=" .. package:dep("libjpeg"):installdir())
  41. end
  42. if package:config("tiff") then
  43. table.insert(configs, "--with-tiff=" .. package:dep("libtiff"):installdir())
  44. end
  45. if package:config("fastfloat") then
  46. table.insert(configs, "--with-fastfloat")
  47. end
  48. if package:config("threaded") then
  49. table.insert(configs, "--with-threaded")
  50. end
  51. if package:config("pic") ~= false then
  52. table.insert(configs, "--with-pic")
  53. end
  54. if package:debug() then
  55. table.insert(configs, "--enable-debug")
  56. end
  57. import("package.tools.autoconf").install(package, configs)
  58. else
  59. table.insert(configs, "-Ddefault_library=" .. (package:config("shared") and "shared" or "static"))
  60. table.insert(configs, "-Djpeg=" .. (package:config("jpeg") and "enabled" or "disabled"))
  61. table.insert(configs, "-Dtiff=" .. (package:config("tiff") and "enabled" or "disabled"))
  62. table.insert(configs, "-Dutils=" .. (package:config("utils") and "true" or "false"))
  63. table.insert(configs, "-Dfastfloat=" .. (package:config("fastfloat") and "true" or "false"))
  64. table.insert(configs, "-Dthreaded=" .. (package:config("threaded") and "true" or "false"))
  65. import("package.tools.meson").install(package, configs)
  66. end
  67. end)
  68. on_test(function (package)
  69. assert(package:has_cfuncs("cmsXYZ2xyY", {includes = "lcms2.h"}))
  70. end)