xmake.lua 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package("c-blosc2")
  2. set_homepage("https://www.blosc.org")
  3. set_description("A fast, compressed, persistent binary data store library for C.")
  4. set_license("BSD-3-Clause")
  5. add_urls("https://github.com/Blosc/c-blosc2/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/Blosc/c-blosc2.git")
  7. add_versions("v2.10.2", "069785bc14c006c7dab40ea0c620bdf3eb8752663fd55c706d145bceabc2a31d")
  8. add_configs("lz4", {description = "Enable LZ4 support.", default = true, type = "boolean"})
  9. add_configs("zlib", {description = "Enable Zlib support.", default = false, type = "boolean"})
  10. add_configs("zstd", {description = "Enable Zstd support.", default = false, type = "boolean"})
  11. add_configs("plugins", {description = "Build plugins programs from the blosc compression library", default = false, type = "boolean"})
  12. add_configs("lite", {description = "Build a lite version (only with BloscLZ and LZ4/LZ4HC) of the blosc library", default = false, type = "boolean"})
  13. if is_plat("linux", "bsd") then
  14. add_syslinks("pthread")
  15. end
  16. add_deps("cmake")
  17. on_load(function (package)
  18. for _, deps in ipairs({"lz4", "zlib", "zstd"}) do
  19. if package:config(deps) then
  20. package:add("deps", deps)
  21. end
  22. end
  23. end)
  24. on_install(function (package)
  25. local configs =
  26. {
  27. "-DBUILD_TESTS=OFF",
  28. "-DBUILD_FUZZERS=OFF",
  29. "-DBUILD_BENCHMARKS=OFF",
  30. "-DBUILD_EXAMPLES=OFF",
  31. }
  32. if package:config("shared") then
  33. table.insert(configs, "-DBUILD_STATIC=OFF")
  34. table.insert(configs, "-DBUILD_SHARED=ON")
  35. else
  36. table.insert(configs, "-DBUILD_STATIC=ON")
  37. table.insert(configs, "-DBUILD_SHARED=OFF")
  38. end
  39. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  40. table.insert(configs, "-DBUILD_PLUGINS=" .. (package:config("plugins") and "ON" or "OFF"))
  41. table.insert(configs, "-DBUILD_LITE=" .. (package:config("lite") and "ON" or "OFF"))
  42. for _, deps in ipairs({"lz4", "zlib", "zstd"}) do
  43. local upper = deps:upper()
  44. table.insert(configs, "-DPREFER_EXTERNAL_" .. upper .. "=ON")
  45. table.insert(configs, "-DDEACTIVATE_" .. upper .. (package:config(deps) and "=OFF" or "=ON"))
  46. end
  47. import("package.tools.cmake").install(package, configs)
  48. -- remove crt dll
  49. if package:is_plat("windows") then
  50. for _, dll in ipairs(os.files(path.join(package:installdir("bin"), "*.dll"))) do
  51. if not path.filename(dll):find("blosc2") then
  52. os.rm(dll)
  53. end
  54. end
  55. end
  56. end)
  57. on_test(function (package)
  58. assert(package:has_cfuncs("blosc2_init", {includes = "blosc2.h"}))
  59. end)