From ca6c75b68b961896fa38ab4a4c168997e61e6bc8 Mon Sep 17 00:00:00 2001 From: ruki Date: Sun, 19 Dec 2021 22:29:12 +0800 Subject: [PATCH] Add highfive and improve hdf5 (#771) * Add high five * fix hdf5 for windows Co-authored-by: Kelvin Zhang --- packages/h/hdf5/xmake.lua | 9 +++++++++ packages/h/highfive/xmake.lua | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 packages/h/highfive/xmake.lua diff --git a/packages/h/hdf5/xmake.lua b/packages/h/hdf5/xmake.lua index d47f2be7b..f768c39e8 100644 --- a/packages/h/hdf5/xmake.lua +++ b/packages/h/hdf5/xmake.lua @@ -21,6 +21,15 @@ package("hdf5") table.insert(configs, "-DONLY_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) table.insert(configs, "-DBUILD_STATIC_LIBS=" .. (package:config("shared") and "OFF" or "ON")) import("package.tools.cmake").install(package, configs) + if package:is_plat("windows") then + -- fix libname to let cmake can find it. + for _, libfile in ipairs(os.files(path.join(package:installdir("lib"), "*.lib"))) do + local basename = path.basename(libfile) + if basename:startswith("lib") then + os.mv(libfile, path.join(path.directory(libfile), basename:sub(4) .. ".lib")) + end + end + end package:addenv("PATH", "bin") end) diff --git a/packages/h/highfive/xmake.lua b/packages/h/highfive/xmake.lua new file mode 100644 index 000000000..8f61b0ce7 --- /dev/null +++ b/packages/h/highfive/xmake.lua @@ -0,0 +1,33 @@ +package("highfive") + set_kind("library", {headeronly = true}) + set_homepage("https://github.com/BlueBrain/HighFive") + set_description("HighFive - Header-only C++ HDF5 interface") + + add_urls("https://github.com/BlueBrain/HighFive/archive/refs/tags/$(version).tar.gz", + "https://github.com/BlueBrain/HighFive.git") + + add_versions("v2.3.1", "41728a1204bdfcdcef8cbc3ddffe5d744c5331434ce3dcef35614b831234fcd7") + + add_deps("cmake") + add_deps("hdf5") + + on_install("windows", "macosx", "linux", function (package) + local configs = {"-DHIGHFIVE_UNIT_TESTS=OFF", + "-DHIGHFIVE_EXAMPLES=OFF", + "-DHIGHFIVE_BUILD_DOCS=OFF", + "-DHIGHFIVE_USE_BOOST=OFF"} + import("package.tools.cmake").install(package, configs) + end) + + on_test(function (package) + assert(package:check_cxxsnippets({test = [[ + #include + using namespace HighFive; + void test() { + File file("/tmp/new_file.h5", File::ReadWrite | File::Create | File::Truncate); + std::vector data(50, 1); + DataSet dataset = file.createDataSet("/dataset_one", DataSpace::From(data)); + dataset.write(data); + } + ]]}, {configs = {languages = "c++17"}})) + end)