Commit 5564c017 authored by Brad King's avatar Brad King

FindHDF5: Restore fallback to static libraries

Since commit v3.6.1~6^2~2 (FindHDF5: Fix h5cc arg parsing to work with
homebrew on Mac, 2016-07-11) we treated `HDF5_USE_STATIC_LIBRARIES` OFF
as a requirement for shared libraries.  It is just supposed to be a
preference.  Even if `HDF5_USE_STATIC_LIBRARIES` is not set we should
still fall back to finding static libraries if shared libraries are not
available.

Issue: #16566
parent 4908969f
......@@ -518,28 +518,26 @@ if(NOT HDF5_FOUND)
)
set(HDF5_${__lang}_LIBRARIES)
set(_HDF5_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
if(HDF5_USE_STATIC_LIBRARIES)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX})
else()
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_SHARED_LIBRARY_SUFFIX})
endif()
foreach(L IN LISTS HDF5_${__lang}_LIBRARY_NAMES)
set(_HDF5_SEARCH_NAMES_LOCAL)
if(x"${L}" MATCHES "hdf5")
# hdf5 library
set(_HDF5_SEARCH_OPTS_LOCAL ${_HDF5_SEARCH_OPTS})
if(UNIX AND HDF5_USE_STATIC_LIBRARIES)
set(_HDF5_SEARCH_NAMES_LOCAL lib${L}.a)
endif()
else()
# external library
set(_HDF5_SEARCH_OPTS_LOCAL)
endif()
find_library(HDF5_${__lang}_LIBRARY_${L}
NAMES ${L}
NAMES ${_HDF5_SEARCH_NAMES_LOCAL} ${L} NAMES_PER_DIR
HINTS ${HDF5_${__lang}_LIBRARY_DIRS}
${HDF5_ROOT}
${_HDF5_SEARCH_OPTS_LOCAL}
)
unset(_HDF5_SEARCH_OPTS_LOCAL)
unset(_HDF5_SEARCH_NAMES_LOCAL)
if(HDF5_${__lang}_LIBRARY_${L})
list(APPEND HDF5_${__lang}_LIBRARIES ${HDF5_${__lang}_LIBRARY_${L}})
else()
......@@ -549,20 +547,25 @@ if(NOT HDF5_FOUND)
if(FIND_HL)
set(HDF5_${__lang}_HL_LIBRARIES)
foreach(L IN LISTS HDF5_${__lang}_HL_LIBRARY_NAMES)
set(_HDF5_SEARCH_NAMES_LOCAL)
if("x${L}" MATCHES "hdf5")
# hdf5 library
set(_HDF5_SEARCH_OPTS_LOCAL ${_HDF5_SEARCH_OPTS})
if(UNIX AND HDF5_USE_STATIC_LIBRARIES)
set(_HDF5_SEARCH_NAMES_LOCAL lib${L}.a)
endif()
else()
# external library
set(_HDF5_SEARCH_OPTS_LOCAL)
endif()
find_library(HDF5_${__lang}_LIBRARY_${L}
NAMES ${L}
NAMES ${_HDF5_SEARCH_NAMES_LOCAL} ${L} NAMES_PER_DIR
HINTS ${HDF5_${__lang}_LIBRARY_DIRS}
${HDF5_ROOT}
${_HDF5_SEARCH_OPTS_LOCAL}
)
unset(_HDF5_SEARCH_OPTS_LOCAL)
unset(_HDF5_SEARCH_NAMES_LOCAL)
if(HDF5_${__lang}_LIBRARY_${L})
list(APPEND HDF5_${__lang}_HL_LIBRARIES ${HDF5_${__lang}_LIBRARY_${L}})
else()
......@@ -572,8 +575,6 @@ if(NOT HDF5_FOUND)
set(HDF5_HL_FOUND True)
endif()
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_HDF5_CMAKE_FIND_LIBRARY_SUFFIXES})
set(HDF5_${__lang}_FOUND True)
mark_as_advanced(HDF5_${__lang}_DEFINITIONS)
mark_as_advanced(HDF5_${__lang}_INCLUDE_DIRS)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment