h5cpp (#1267)
* hdf5: add cpp build option * rename option * create h5cpp package * use cmake internal find hdf5 script * constrain platform * fix dll linkpull/1271/head
parent
7f99ab129d
commit
869f092105
5 changed files with 148 additions and 11 deletions
@ -0,0 +1,79 @@ |
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index c50784b3..dd97d117 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -171,11 +171,6 @@ install(FILES
|
||||
DESTINATION ${CMAKE_INSTALL_PACKAGEDIR}
|
||||
COMPONENT development)
|
||||
|
||||
-install(FILES
|
||||
- cmake/FindHDF5.cmake
|
||||
- DESTINATION ${CMAKE_INSTALL_PACKAGEDIR}/hdf5
|
||||
- COMPONENT development)
|
||||
-
|
||||
#
|
||||
# uninstall target
|
||||
#
|
||||
diff --git a/cmake/HDF5LibraryConfig.cmake b/cmake/HDF5LibraryConfig.cmake
|
||||
index c05fe75f..7461f5ea 100644
|
||||
--- a/cmake/HDF5LibraryConfig.cmake
|
||||
+++ b/cmake/HDF5LibraryConfig.cmake
|
||||
@@ -2,22 +2,24 @@ if(H5CPP_WITH_MPI)
|
||||
set(HDF5_PREFER_PARALLEL TRUE)
|
||||
endif()
|
||||
|
||||
-find_package(HDF5 REQUIRED COMPONENTS C HL)
|
||||
+find_package(HDF5 CONFIG REQUIRED COMPONENTS C HL)
|
||||
+if(H5CPP_BUILD_SHARED)
|
||||
+ set(libtype SHARED)
|
||||
+else()
|
||||
+ set(libtype STATIC)
|
||||
+endif()
|
||||
message(STATUS "==============================================================")
|
||||
message(STATUS "========================Found HDF5============================")
|
||||
message(STATUS "==============================================================")
|
||||
-message(STATUS "Found HDF5 libraries in: ${HDF5_LIBRARY_DIRS}")
|
||||
-message(STATUS "Found HDF5 libraries: ${HDF5_LIBRARIES}")
|
||||
-message(STATUS "Found HDF5 HL libraries: ${HDF5_HL_LIBRARIES}")
|
||||
-message(STATUS "Found HDF5 headers: ${HDF5_INCLUDE_DIRS}")
|
||||
-message(STATUS "Found HDF5 definitions: ${HDF5_DEFINITIONS}")
|
||||
+message(STATUS "Found HDF5 libraries: ${HDF5_EXPORT_LIBRARIES}")
|
||||
+message(STATUS "Found HDF5 headers: ${HDF5_INCLUDE_DIR}")
|
||||
message(STATUS "Found HDF5 HDF5_VERSION = ${HDF5_VERSION}")
|
||||
-message(STATUS "Found HDF5 HDF5_IS_PARALLEL = ${HDF5_IS_PARALLEL}")
|
||||
+message(STATUS "Found HDF5 HDF5_ENABLE_PARALLEL = ${HDF5_ENABLE_PARALLEL}")
|
||||
message(STATUS "==============================================================")
|
||||
|
||||
|
||||
if(H5CPP_WITH_MPI)
|
||||
- if(NOT HDF5_IS_PARALLEL)
|
||||
+ if(NOT HDF5_ENABLE_PARALLEL)
|
||||
message(FATAL_ERROR "The HDF5 version found does not support MPI")
|
||||
endif()
|
||||
endif()
|
||||
diff --git a/src/h5cpp/CMakeLists.txt b/src/h5cpp/CMakeLists.txt
|
||||
index 03a98885..0c8cd9de 100644
|
||||
--- a/src/h5cpp/CMakeLists.txt
|
||||
+++ b/src/h5cpp/CMakeLists.txt
|
||||
@@ -39,6 +39,9 @@ add_doxygen_source_deps(${h5cpp_headers})
|
||||
|
||||
if (H5CPP_BUILD_SHARED)
|
||||
target_compile_definitions(h5cpp PRIVATE H5CPP_EXPORTS PUBLIC H5CPP_BUILD_SHARED)
|
||||
+ set(_suffix "shared")
|
||||
+else()
|
||||
+ set(_suffix "static")
|
||||
endif()
|
||||
|
||||
set(H5CPP_LINKS ${MPI_CXX_LIBRARIES})
|
||||
@@ -86,9 +89,9 @@ endif()
|
||||
target_link_libraries(h5cpp
|
||||
PUBLIC
|
||||
${H5CPP_LINKS}
|
||||
- hdf5::hdf5
|
||||
+ "hdf5::hdf5-${_suffix}"
|
||||
PRIVATE ${COVERAGE_LIBRARIES}
|
||||
- hdf5::hdf5_hl
|
||||
+ "hdf5::hdf5_hl-${_suffix}"
|
||||
Threads::Threads
|
||||
${H5CPP_FILTER_TARGETS}
|
||||
${CMAKE_DL_LIBS}
|
@ -0,0 +1,42 @@ |
||||
package("h5cpp") |
||||
set_homepage("https://ess-dmsc.github.io/h5cpp/") |
||||
set_description("C++ wrapper for the HDF5 C-library") |
||||
set_license("LGPL-2.1") |
||||
|
||||
add_urls("https://github.com/ess-dmsc/h5cpp/archive/refs/tags/$(version).tar.gz", |
||||
"https://github.com/ess-dmsc/h5cpp.git") |
||||
add_versions("v0.5.1", "8fcab57ffbc2d799fe315875cd8fcf67e8b059cccc441ea45a001c03f6a9fd25") |
||||
|
||||
add_patches("v0.5.1", path.join(os.scriptdir(), "patches", "fix-find-hdf5.patch"), "25f26ec6994d387571d7c068ba0405a34db45480a9c17fe3ea6402042e7de87c") |
||||
|
||||
add_deps("cmake") |
||||
add_deps("zlib") |
||||
|
||||
on_load(function (package) |
||||
package:add("deps", "hdf5", { configs = {shared = package:config("shared")} }) |
||||
end) |
||||
|
||||
on_install("windows", "macosx", "linux", function (package) |
||||
os.rm("cmake/FindHDF5.cmake") |
||||
local configs = { |
||||
"-DH5CPP_WITH_BOOST=OFF", |
||||
"-DH5CPP_CONAN=DISABLE", |
||||
"-DH5CPP_DISABLE_TESTS=ON", |
||||
"-DH5CPP_BUILD_DOCS=OFF" |
||||
} |
||||
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release")) |
||||
table.insert(configs, "-DH5CPP_BUILD_SHARED=" .. (package:config("shared") and "ON" or "OFF")) |
||||
if is_plat("windows") and package:config("shared") then |
||||
package:add("defines", "H5_BUILT_AS_DYNAMIC_LIB") |
||||
end |
||||
import("package.tools.cmake").install(package, configs, {packagedeps = {"hdf5"}}) |
||||
package:addenv("PATH", package:installdir("bin")) |
||||
end) |
||||
|
||||
on_test(function (package) |
||||
assert(package:check_cxxsnippets({test = [[ |
||||
void test() { |
||||
auto type = hdf5::datatype::TypeTrait<int>::create(); |
||||
} |
||||
]]}, {configs = {languages = "c++17"}, includes = {"h5cpp/hdf5.hpp"}})) |
||||
end) |
@ -0,0 +1,16 @@ |
||||
diff --git a/CMake/HighFiveTargetDeps.cmake b/CMake/HighFiveTargetDeps.cmake
|
||||
index 50c3e9d..83ea21b 100644
|
||||
--- a/CMake/HighFiveTargetDeps.cmake
|
||||
+++ b/CMake/HighFiveTargetDeps.cmake
|
||||
@@ -8,9 +8,9 @@ if(NOT TARGET libdeps)
|
||||
|
||||
# HDF5
|
||||
if(NOT DEFINED HDF5_C_LIBRARIES)
|
||||
- set(HDF5_NO_FIND_PACKAGE_CONFIG_FILE TRUE) # Consistency
|
||||
+ set(HDF5_NO_FIND_PACKAGE_CONFIG_FILE FALSE) # use config
|
||||
set(HDF5_PREFER_PARALLEL ${HIGHFIVE_PARALLEL_HDF5})
|
||||
- find_package(HDF5 REQUIRED)
|
||||
+ find_package(HDF5 REQUIRED HINTS ${HDF5_ROOT})
|
||||
endif()
|
||||
|
||||
if(HIGHFIVE_PARALLEL_HDF5 AND NOT HDF5_IS_PARALLEL)
|
Loading…
Reference in new issue