xmake.lua 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package("hdf5")
  2. set_homepage("https://www.hdfgroup.org/solutions/hdf5/")
  3. set_description("High-performance data management and storage suite")
  4. set_license("BSD-3-Clause")
  5. add_urls("https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-$(version).tar.gz", {version = function (version)
  6. return format("%d.%d/hdf5-%s/src/hdf5-%s", version:major(), version:minor(), version, version)
  7. end})
  8. add_versions("1.12.0", "a62dcb276658cb78e6795dd29bf926ed7a9bc4edf6e77025cd2c689a8f97c17a")
  9. add_versions("1.12.1", "79c66ff67e666665369396e9c90b32e238e501f345afd2234186bfb8331081ca")
  10. add_configs("cpplib", {description = "Build HDF5 C++ Library", default = false, type = "boolean"})
  11. add_deps("cmake")
  12. if is_plat("linux") then
  13. add_syslinks("dl")
  14. end
  15. on_install("windows", "macosx", "linux", function (package)
  16. local configs = {
  17. "-DHDF5_GENERATE_HEADERS=OFF",
  18. "-DBUILD_TESTING=OFF",
  19. "-DHDF5_BUILD_EXAMPLES=OFF",
  20. "-DHDF_PACKAGE_NAMESPACE:STRING=hdf5::",
  21. "-DHDF5_MSVC_NAMING_CONVENTION=OFF"
  22. }
  23. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  24. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  25. table.insert(configs, "-DONLY_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  26. table.insert(configs, "-DBUILD_STATIC_LIBS=" .. (package:config("shared") and "OFF" or "ON"))
  27. table.insert(configs, "-DHDF5_BUILD_CPP_LIB=" .. (package:config("cpplib") and "ON" or "OFF"))
  28. import("package.tools.cmake").install(package, configs)
  29. package:addenv("HDF5_ROOT", path.join(package:installdir("share"), "cmake"))
  30. package:addenv("PATH", package:installdir("bin"))
  31. end)
  32. on_test(function (package)
  33. if package:config("shared") then
  34. os.vrun("h5diff-shared --version")
  35. else
  36. os.vrun("h5diff --version")
  37. end
  38. assert(package:has_cfuncs("H5open", {includes = "H5public.h"}))
  39. if package:config("cpplib") then
  40. assert(package:check_cxxsnippets({test = [[
  41. void test() {
  42. H5::H5Library::open();
  43. }
  44. ]]}, {configs = {languages = "c++17"}, includes = {"H5Cpp.h"}}))
  45. end
  46. end)