Make sure HDF5_C_LIBRARY and HDF5_HL_LIBRARY set

On some versions of the HDF5 find_package call, it sets `HDF5_C_LIBRARIES` and `HDF5_HL_LIBRARIES`, but does not set the `HDF5_C_LIBRARY` or `HDF5_HL_LIBRARY` to anything.  Control then falls out of the if block with these unset and it falls into the default setting at line 792.  This does not include the path, so then when the later `CHECK_LIBRARY_EXISTS` calls are run, they do not have the full path to the library and will not link correctly.  Since the link fails, the code defaults to thinking that none of the symbols are defined.

I don't think this change will have any affect since it only sets the symbols if they are unset.
This commit is contained in:
Greg Sjaardema 2021-10-01 13:34:58 -06:00 committed by GitHub
parent de403a0fe8
commit 6b8a940ab2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -745,6 +745,11 @@ IF(USE_HDF5)
# HDF5_C_LIBRARY, HDF5_HL_LIBRARY and HDF5_LIBRARIES.
###
IF(MSVC)
####
# Environmental variables in Windows when using MSVC
# are a hot mess between versions.
####
##
# HDF5 1.8.15 defined HDF5_LIBRARIES.
##
@ -764,10 +769,6 @@ IF(USE_HDF5)
ENDIF(${HDF5_VERSION} VERSION_GREATER "1.8.15")
ELSE(MSVC)
####
# Environmental variables in Windows when using MSVC
# are a hot mess between versions.
####
# Depending on the install, either HDF5_hdf_library or
# HDF5_C_LIBRARIES may be defined. We must check for either.
@ -775,6 +776,17 @@ IF(USE_HDF5)
SET(HDF5_hdf5_LIBRARY ${HDF5_C_LIBRARIES})
ENDIF()
# Some versions of FIND_PACKAGE set HDF5_C_LIBRARIES, but not HDF5_C_LIBRARY
# We use HDF5_C_LIBRARY below, so need to make sure it is set.
IF(HDF5_C_LIBRARIES AND NOT HDF5_C_LIBRARY)
SET(HDF5_C_LIBRARY ${HDF5_C_LIBRARIES})
ENDIF()
# Same issue as above...
IF(HDF5_HL_LIBRARIES AND NOT HDF5_HL_LIBRARY)
SET(HDF5_HL_LIBRARY ${HDF5_HL_LIBRARIES})
ENDIF()
ENDIF(MSVC)
IF(NOT HDF5_C_LIBRARY)
SET(HDF5_C_LIBRARY hdf5)