diff options
author | Kris Thielemans <kris.f.thielemans@hotmail.com> | 2017-02-06 01:27:56 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-03-01 13:12:56 (GMT) |
commit | b2de6da2f161cde26178e568974fa5ef7f7480fc (patch) | |
tree | d2575c1fcfe87cb3a4da433a6ce48387e08de1b6 /Modules/FindHDF5.cmake | |
parent | 003c91385a050fc3b469e9f4d1ccf22e70f0f709 (diff) | |
download | CMake-b2de6da2f161cde26178e568974fa5ef7f7480fc.zip CMake-b2de6da2f161cde26178e568974fa5ef7f7480fc.tar.gz CMake-b2de6da2f161cde26178e568974fa5ef7f7480fc.tar.bz2 |
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
Diffstat (limited to 'Modules/FindHDF5.cmake')
-rw-r--r-- | Modules/FindHDF5.cmake | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index ae2c707..a85b9ac 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -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}) |