Procházet zdrojové kódy

Add highfive and improve hdf5 (#771)

* Add high five

* fix hdf5 for windows

Co-authored-by: Kelvin Zhang <[email protected]>
ruki před 3 roky
rodič
revize
ca6c75b68b
2 změnil soubory, kde provedl 42 přidání a 0 odebrání
  1. 9 0
      packages/h/hdf5/xmake.lua
  2. 33 0
      packages/h/highfive/xmake.lua

+ 9 - 0
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)
 

+ 33 - 0
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 <highfive/H5File.hpp>
+        using namespace HighFive;
+        void test() {
+            File file("/tmp/new_file.h5", File::ReadWrite | File::Create | File::Truncate);
+            std::vector<int> data(50, 1);
+            DataSet dataset = file.createDataSet<int>("/dataset_one",  DataSpace::From(data));
+            dataset.write(data);
+        }
+        ]]}, {configs = {languages = "c++17"}}))
+    end)