xmake.lua 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package("matio")
  2. set_homepage("https://matio.sourceforge.io")
  3. set_description("MATLAB MAT File I/O Library")
  4. set_license("BSD-2-Clause")
  5. add_urls("https://github.com/tbeu/matio/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/tbeu/matio.git", {submodules = false})
  7. add_versions("v1.5.29", "345f18bad65ad4a736ef5b4d660e8587c672939ff88b8551453e03d2146ff8b0")
  8. add_versions("v1.5.28", "04d14160a637ea822593c336b231227372179f650250c98024a8a2b744afef25")
  9. add_versions("v1.5.27", "2efe7c4a206885287c0f56128f3a36aa6e453077d03e4c2c42cdce9d332b67eb")
  10. add_versions("v1.5.26", "4aa5ac827ee49a3111f88f8d9b8ae034b8757384477e8f29cb64582c7d54e156")
  11. add_configs("zlib", {description = "Build with zlib support", default = false, type = "boolean"})
  12. add_configs("hdf5", {description = "Build with hdf5 support", default = false, type = "boolean"})
  13. add_configs("extended_sparse", {description = "Enable extended sparse matrix data types not supported in MATLAB", default = false, type = "boolean"})
  14. add_configs("mat73", {description = "Enable support for version 7.3 MAT files", default = false, type = "boolean"})
  15. add_configs("default_file_version", {description = "Select what MAT file format version is used by default", default = "5", type = "string", values = {"4", "5", "7.5"}})
  16. if is_plat("wasm") then
  17. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  18. end
  19. add_deps("cmake")
  20. on_load(function (package)
  21. if package:config("zlib") then
  22. package:add("deps", "zlib >=1.2.3")
  23. end
  24. if package:config("hdf5") then
  25. package:add("deps", "hdf5 >=1.8.x")
  26. end
  27. end)
  28. on_install("windows", "linux", "macosx", "bsd", "android", "iphoneos", "cross", "wasm", function (package)
  29. local configs = {}
  30. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  31. table.insert(configs, "-DMATIO_SHARED=" .. (package:config("shared") and "ON" or "OFF"))
  32. table.insert(configs, "-DMATIO_PIC=" .. (package:config("pic") and "ON" or "OFF"))
  33. table.insert(configs, "-DMATIO_WITH_ZLIB=" .. (package:config("zlib") and "ON" or "OFF"))
  34. table.insert(configs, "-DMATIO_WITH_HDF5=" .. (package:config("hdf5") and "ON" or "OFF"))
  35. table.insert(configs, "-DMATIO_EXTENDED_SPARSE=" .. (package:config("extended_sparse") and "ON" or "OFF"))
  36. table.insert(configs, "-DMATIO_MAT73=" .. (package:config("mat73") and "ON" or "OFF"))
  37. table.insert(configs, "-DMATIO_DEFAULT_FILE_VERSION=" .. package:config("default_file_version"))
  38. io.replace("CMakeLists.txt", "include(cmake/tools.cmake)", "", {plain = true})
  39. io.replace("CMakeLists.txt", "include(cmake/test.cmake)", "", {plain = true})
  40. local packagedeps = {}
  41. if package:config("hdf5") then
  42. table.insert(packagedeps, "hdf5")
  43. end
  44. import("package.tools.cmake").install(package, configs, {packagedeps = packagedeps})
  45. end)
  46. on_test(function (package)
  47. assert(package:has_cfuncs("Mat_Open", {includes = "matio.h"}))
  48. end)