mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-02 11:49:55 -06:00
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
This commit is contained in:
committed by
Brad King
parent
003c91385a
commit
b2de6da2f1
@@ -436,8 +436,13 @@ if(NOT HDF5_FOUND)
|
||||
if(HDF5_FIND_DEBUG)
|
||||
message(STATUS "Trying to get properties of target ${HDF5_${_lang}_TARGET}${_suffix}")
|
||||
endif()
|
||||
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)
|
||||
endif()
|
||||
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)
|
||||
endif()
|
||||
if(FIND_HL)
|
||||
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)
|
||||
endif()
|
||||
if( _lang_hl_location )
|
||||
set(HDF5_${_lang}_HL_LIBRARY ${_lang_hl_location})
|
||||
list(APPEND HDF5_HL_LIBRARIES ${HDF5_${_lang}_TARGET}${_suffix})
|
||||
|
||||
Reference in New Issue
Block a user