diff --git a/cmake/HDF5TargetUtils.cmake b/cmake/HDF5TargetUtils.cmake index 3b36e1c0..2962203e 100644 --- a/cmake/HDF5TargetUtils.cmake +++ b/cmake/HDF5TargetUtils.cmake @@ -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- (self-contained) + # CMake version >= 3.19 defines target hdf5::hdf5_hl (not self-contained) + # hdf5-config.cmake from source defines target hdf5_hl- (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() diff --git a/cmake/SetupDependencies.cmake b/cmake/SetupDependencies.cmake index 9272c125..869f5074 100644 --- a/cmake/SetupDependencies.cmake +++ b/cmake/SetupDependencies.cmake @@ -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) + diff --git a/cmake/modules/FindHDF5.cmake b/cmake/modules/FindHDF5-DEPRECATED.cmake similarity index 98% rename from cmake/modules/FindHDF5.cmake rename to cmake/modules/FindHDF5-DEPRECATED.cmake index 5b02dfcf..ed97e2f3 100644 --- a/cmake/modules/FindHDF5.cmake +++ b/cmake/modules/FindHDF5-DEPRECATED.cmake @@ -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, @@ -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)