xmake.lua 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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.27", "2efe7c4a206885287c0f56128f3a36aa6e453077d03e4c2c42cdce9d332b67eb")
  8. add_versions("v1.5.26", "4aa5ac827ee49a3111f88f8d9b8ae034b8757384477e8f29cb64582c7d54e156")
  9. add_configs("zlib", {description = "Build with zlib support", default = false, type = "boolean"})
  10. add_configs("hdf5", {description = "Build with hdf5 support", default = false, type = "boolean"})
  11. add_configs("extended_sparse", {description = "Enable extended sparse matrix data types not supported in MATLAB", default = false, type = "boolean"})
  12. add_configs("mat73", {description = "Enable support for version 7.3 MAT files", default = false, type = "boolean"})
  13. 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"}})
  14. add_deps("cmake")
  15. on_load(function (package)
  16. if package:config("zlib") then
  17. package:add("deps", "zlib >=1.2.3")
  18. end
  19. if package:config("hdf5") then
  20. package:add("deps", "hdf5 >=1.8.x")
  21. end
  22. end)
  23. on_install("windows", "linux", "macosx", "bsd", "android", "iphoneos", "cross", "wasm", function (package)
  24. local configs = {}
  25. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  26. table.insert(configs, "-DMATIO_SHARED=" .. (package:config("shared") and "ON" or "OFF"))
  27. table.insert(configs, "-DMATIO_PIC=" .. (package:config("pic") and "ON" or "OFF"))
  28. table.insert(configs, "-DMATIO_WITH_ZLIB=" .. (package:config("zlib") and "ON" or "OFF"))
  29. table.insert(configs, "-DMATIO_WITH_HDF5=" .. (package:config("hdf5") and "ON" or "OFF"))
  30. table.insert(configs, "-DMATIO_EXTENDED_SPARSE=" .. (package:config("extended_sparse") and "ON" or "OFF"))
  31. table.insert(configs, "-DMATIO_MAT73=" .. (package:config("mat73") and "ON" or "OFF"))
  32. table.insert(configs, "-DMATIO_DEFAULT_FILE_VERSION=" .. package:config("default_file_version"))
  33. io.replace("CMakeLists.txt", "include(cmake/tools.cmake)", "", {plain = true})
  34. io.replace("CMakeLists.txt", "include(cmake/test.cmake)", "", {plain = true})
  35. local packagedeps = {}
  36. if package:config("hdf5") then
  37. table.insert(packagedeps, "hdf5")
  38. end
  39. import("package.tools.cmake").install(package, configs, {packagedeps = packagedeps})
  40. end)
  41. on_test(function (package)
  42. assert(package:has_cfuncs("Mat_Open", {includes = "matio.h"}))
  43. end)