Skip to content

Commit

Permalink
Deprecated the custom FindHDF5 module bundled by h5pp
Browse files Browse the repository at this point in the history
* CMake now does the right thing when linking HDF5::HDF5
  • Loading branch information
DavidAce committed Mar 14, 2024
1 parent 87e12a5 commit 91c0f42
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 22 deletions.
8 changes: 4 additions & 4 deletions cmake/HDF5TargetUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ function(h5pp_get_modern_hdf5_target_name)
# FindHDF5.cmake bundled with h5pp defines target HDF5::HDF5 with everything (self-contained)
# Conan also defines a target HDF5::HDF5 with everything (self-contained)
# CMake version >= 3.20 defines target HDF5::HDF5 with imp lib only (not self-contained)
# CMake version >= 3.19 define target hdf5::hdf5_hl (not self-contained)
# hdf5-config.cmake from source installations will define target hdf5_hl-<static|shared> (self-contained)
# CMake version >= 3.19 defines target hdf5::hdf5_hl (not self-contained)
# hdf5-config.cmake from source defines target hdf5_hl-<static|shared> (self-contained)

if(NOT HDF5_FOUND)
message(FATAL_ERROR "h5pp_get_modern_hdf5_target_name: this function should only be called after a successful call to find_package(HDF5)")
message(FATAL_ERROR "h5pp_get_modern_hdf5_target_name: HDF5_FOUND is not TRUE. Call find_package(HDF5) first.")
endif()

# If HDF5::ALIAS is a sentinel target from h5pp-bundled FindHDF5.cmake
# so, if it is defined then we expect HDF5::HDF5 to be self-contained
if(TARGET HDF5::HDF5 AND TARGET HDF5::ALIAS)
message(VERBOSE "Found good HDF5::HDF5 target from h5pp-bundled FindHDF5.cmake")
message(VERBOSE "h5pp_get_modern_hdf5_target_name: Found a good HDF5::HDF5 target from h5pp-bundled FindHDF5.cmake")
return()
endif()

Expand Down
11 changes: 3 additions & 8 deletions cmake/SetupDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,11 @@ if(H5PP_ENABLE_SPDLOG)
target_compile_definitions(deps INTERFACE H5PP_USE_SPDLOG)
endif()

# Note that the call below defaults to FindHDF5.cmake bundled with h5pp,
# because cmake/modules has been added to CMAKE_MODULE_PATH in cmake/SetupPaths.cmake
# Also, we don't impose any version requirement here: h5pp is compatible with 1.8 to 1.14.
find_package(ZLIB QUIET)
find_package(SZIP QUIET)

# We don't impose any version requirement here: h5pp is compatible with 1.8 to 1.14.
find_package(HDF5 COMPONENTS C HL REQUIRED)
if(HDF5_VERSION AND HDF5_VERSION VERSION_LESS 1.8)
message(FATAL_ERROR "Found version ${HDF5_VERSION} < 1.8 required by h5pp")
endif()
include(cmake/HDF5TargetUtils.cmake)
h5pp_get_modern_hdf5_target_name()
target_link_libraries(deps INTERFACE HDF5::HDF5)

Check failure on line 71 in cmake/SetupDependencies.cmake

View workflow job for this annotation

GitHub Actions / cl-cmake

The link interface of target "deps" contains:

Check failure on line 71 in cmake/SetupDependencies.cmake

View workflow job for this annotation

GitHub Actions / cl-cmake

The link interface of target "deps" contains:

Check failure on line 71 in cmake/SetupDependencies.cmake

View workflow job for this annotation

GitHub Actions / cl-cmake

The link interface of target "deps" contains:

Check failure on line 71 in cmake/SetupDependencies.cmake

View workflow job for this annotation

GitHub Actions / clang-cmake

The link interface of target "deps" contains:


Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

# If CMake version >= 3.19 this module will simply pass through to CMake's built-in
# module FindHDF5.cmake.
# If CMake version < 3.19 this module replaces CMake's own FindHDF5.cmake module, in an attempt to
# mimic the
# If CMake version < 3.19 this module replaces CMake's own FindHDF5.cmake module



# The motivation for this wrapper module is that the naming conventions of HDF5 targets, variables,
Expand Down Expand Up @@ -577,18 +577,19 @@ endfunction()



find_package_hdf5()

if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.19)
set(HANDLE_VERSION_RANGE HANDLE_VERSION_RANGE)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(HDF5
REQUIRED_VARS HDF5_INCLUDE_DIRS HDF5_TARGETS
VERSION_VAR HDF5_VERSION
HANDLE_COMPONENTS
HANDLE_VERSION_RANGE
)
else()
find_package_hdf5()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(HDF5
REQUIRED_VARS HDF5_INCLUDE_DIRS HDF5_TARGETS
VERSION_VAR HDF5_VERSION
HANDLE_COMPONENTS
${HANDLE_VERSION_RANGE}
)

# To print all variables, use the code below:
#get_cmake_property(_variableNames VARIABLES)
Expand Down

0 comments on commit 91c0f42

Please sign in to comment.