Bladeren bron

hdf5: add cpp build option (#1265)

* hdf5: add cpp build option

* rename option
L-Sun 3 jaren geleden
bovenliggende
commit
b267ba5bb6
1 gewijzigde bestanden met toevoegingen van 11 en 0 verwijderingen
  1. 11 0
      packages/h/hdf5/xmake.lua

+ 11 - 0
packages/h/hdf5/xmake.lua

@@ -10,6 +10,8 @@ package("hdf5")
     add_versions("1.12.0", "a62dcb276658cb78e6795dd29bf926ed7a9bc4edf6e77025cd2c689a8f97c17a")
     add_versions("1.12.1", "79c66ff67e666665369396e9c90b32e238e501f345afd2234186bfb8331081ca")
 
+    add_configs("cpplib", {description = "Build HDF5 C++ Library", default = false, type = "boolean"})
+
     add_deps("cmake")
     if is_plat("linux") then
         add_syslinks("dl")
@@ -20,6 +22,7 @@ package("hdf5")
         table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
         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"))
+        table.insert(configs, "-DHDF5_BUILD_CPP_LIB=" .. (package:config("cpplib") and "ON" or "OFF"))
         import("package.tools.cmake").install(package, configs)
         if package:is_plat("windows") then
             -- fix libname to let cmake can find it.
@@ -40,4 +43,12 @@ package("hdf5")
             os.vrun("h5diff --version")
         end
         assert(package:has_cfuncs("H5open", {includes = "H5public.h"}))
+
+        if package:config("cpplib") then
+             assert(package:check_cxxsnippets({test = [[
+                void test() {
+                    H5::H5Library::open();
+                }
+            ]]}, {configs = {languages = "c++17"}, includes = {"H5Cpp.h"}}))
+        end
     end)