Skip to content

Commit

Permalink
matio: add package (#2836)
Browse files Browse the repository at this point in the history
* matio: add package

* remove test and tool

* disable plat
  • Loading branch information
star-hengxing authored Nov 17, 2023
1 parent 10697d7 commit bb6ee95
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions packages/m/matio/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package("matio")
set_homepage("https://matio.sourceforge.io")
set_description("MATLAB MAT File I/O Library")
set_license("BSD-2-Clause")

add_urls("https://github.com/tbeu/matio/archive/refs/tags/$(version).tar.gz",
"https://github.com/tbeu/matio.git", {submodules = false})

add_versions("v1.5.26", "4aa5ac827ee49a3111f88f8d9b8ae034b8757384477e8f29cb64582c7d54e156")

add_configs("zlib", {description = "Build with zlib support", default = false, type = "boolean"})
add_configs("hdf5", {description = "Build with hdf5 support", default = false, type = "boolean"})
add_configs("extended_sparse", {description = "Enable extended sparse matrix data types not supported in MATLAB", default = false, type = "boolean"})
add_configs("mat73", {description = "Enable support for version 7.3 MAT files", default = false, type = "boolean"})
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"}})

add_deps("cmake")

on_load(function (package)
if package:config("zlib") then
package:add("deps", "zlib >=1.2.3")
end
if package:config("hdf5") then
package:add("deps", "hdf5 >=1.8.x")
end
end)

on_install("windows", "linux", "macosx", "bsd", "android", "iphoneos", "cross", "wasm", function (package)
local configs = {}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
table.insert(configs, "-DMATIO_SHARED=" .. (package:config("shared") and "ON" or "OFF"))
table.insert(configs, "-DMATIO_PIC=" .. (package:config("pic") and "ON" or "OFF"))
table.insert(configs, "-DMATIO_WITH_ZLIB=" .. (package:config("zlib") and "ON" or "OFF"))
table.insert(configs, "-DMATIO_WITH_HDF5=" .. (package:config("hdf5") and "ON" or "OFF"))
table.insert(configs, "-DMATIO_EXTENDED_SPARSE=" .. (package:config("extended_sparse") and "ON" or "OFF"))
table.insert(configs, "-DMATIO_MAT73=" .. (package:config("mat73") and "ON" or "OFF"))
table.insert(configs, "-DMATIO_DEFAULT_FILE_VERSION=" .. package:config("default_file_version"))
io.replace("CMakeLists.txt", "include(cmake/tools.cmake)", "", {plain = true})
io.replace("CMakeLists.txt", "include(cmake/test.cmake)", "", {plain = true})
import("package.tools.cmake").install(package, configs)
end)

on_test(function (package)
assert(package:has_cfuncs("Mat_Open", {includes = "matio.h"}))
end)

0 comments on commit bb6ee95

Please sign in to comment.