diff options
author | Brad King <brad.king@kitware.com> | 2017-02-03 13:51:52 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-02-03 14:12:06 (GMT) |
commit | 5564c01703c20f992769f4e152bcc74ceddc5942 (patch) | |
tree | 0695901665ed64b43a20498b6fea892e313abeec /Modules/FindHDF5.cmake | |
parent | 4908969f578ded9d87f244bd8ada65ba0c51cf28 (diff) | |
download | CMake-5564c01703c20f992769f4e152bcc74ceddc5942.zip CMake-5564c01703c20f992769f4e152bcc74ceddc5942.tar.gz CMake-5564c01703c20f992769f4e152bcc74ceddc5942.tar.bz2 |
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
Diffstat (limited to 'Modules/FindHDF5.cmake')
-rw-r--r-- | Modules/FindHDF5.cmake | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index 94a8729..b10e313 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -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) |