Commit b2de6da2 authored by Kris Thielemans's avatar Kris Thielemans Committed by Brad King

FindHDF5: use import libraries when using hdf5-config.cmake on Windows

The `LOCATION` of imported shared libraries on Windows is that of the
`.dll`.  Use the import library instead to get the `.lib` to be linked.

Fixes: #16534
parent 003c9138
......@@ -436,8 +436,13 @@ if(NOT HDF5_FOUND)
message(STATUS "Trying to get properties of target ${HDF5_${_lang}_TARGET}${_suffix}")
get_target_property(_lang_location ${HDF5_${_lang}_TARGET}${_suffix} LOCATION)
# Find library for this target. Complicated as on Windows with a DLL, we need to search for the import-lib.
get_target_property(_imported_conf ${HDF5_${_lang}_TARGET}${_suffix} IMPORTED_CONFIGURATIONS)
get_target_property(_lang_location ${HDF5_${_lang}_TARGET}${_suffix} IMPORTED_IMPLIB_${_imported_conf} )
if (NOT _lang_location)
# no import lib, just try LOCATION
get_target_property(_lang_location ${HDF5_${_lang}_TARGET}${_suffix} LOCATION)
if( _lang_location )
set(HDF5_${_lang}_LIBRARY ${_lang_location})
list(APPEND HDF5_LIBRARIES ${HDF5_${_lang}_TARGET}${_suffix})
......@@ -445,7 +450,10 @@ if(NOT HDF5_FOUND)
set(HDF5_${_lang}_FOUND True)
get_target_property(_lang_hl_location ${HDF5_${_lang}_HL_TARGET}${_suffix} LOCATION)
get_target_property(__lang_hl_location ${HDF5_${_lang}_HL_TARGET}${_suffix} IMPORTED_IMPLIB_${_imported_conf} )
if (NOT _lang_hl_location)
get_target_property(_lang_hl_location ${HDF5_${_lang}_HL_TARGET}${_suffix} LOCATION)
if( _lang_hl_location )
set(HDF5_${_lang}_HL_LIBRARY ${_lang_hl_location})
list(APPEND HDF5_HL_LIBRARIES ${HDF5_${_lang}_TARGET}${_suffix})
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