Skip to content

Commit 57d74e8

Browse files
committed
HDF5 built with cmake may produce invalid "Extra libraries"
Check the extra libraries with AC_LINK_IFELSE. When failed, skip adding it to LIBS
1 parent 2075e60 commit 57d74e8

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

configure.ac

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,27 @@ if test "x$have_hdf5" = xyes ; then
807807
extra_libs="`grep 'Extra libraries' $hdf5_lib/libhdf5.settings |cut -f2 -d:`"
808808
AC_MSG_RESULT([$extra_libs])
809809
fi
810+
811+
# Building HDF5 1.14.6 using cmake produces an incorrect results in the field of
812+
# "Extra libraries". Test it first before including it to LIBS.
813+
if test "x$extra_libs" != x ; then
814+
saved_LIBS=$LIBS
815+
if test "x$LIBS" = x ; then
816+
LIBS="-lhdf5 $extra_libs"
817+
else
818+
LIBS="-lhdf5 $extra_libs $LIBS"
819+
fi
820+
AC_MSG_CHECKING([extra libraries shown in libhdf5.settings if valid])
821+
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <hdf5.h>]],
822+
[[H5Fopen("dummy", H5F_ACC_RDWR, H5P_DEFAULT);]])],
823+
[valid_extra_libs=yes], [valid_extra_libs=no])
824+
AC_MSG_RESULT([$valid_extra_libs])
825+
if test "x$valid_extra_libs" = xno ; then
826+
extra_libs=
827+
fi
828+
LIBS=$saved_LIBS
829+
fi
830+
810831
if test "x$LIBS" = x ; then
811832
LIBS="-lhdf5 $extra_libs"
812833
else

0 commit comments

Comments
 (0)