From de59f3804da884feaee02734f89da37be8c2bc66 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Thu, 11 May 2023 16:17:23 -0400 Subject: [PATCH] Allow finding user-installed HDF5 --- cmake/modules/FindDEAL_II_HDF5.cmake | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/cmake/modules/FindDEAL_II_HDF5.cmake b/cmake/modules/FindDEAL_II_HDF5.cmake index d6ff4cf6dd..3bdf48fe08 100644 --- a/cmake/modules/FindDEAL_II_HDF5.cmake +++ b/cmake/modules/FindDEAL_II_HDF5.cmake @@ -35,7 +35,27 @@ set(HDF5_PREFER_PARALLEL TRUE) find_package(HDF5) set(_include_dirs "${HDF5_INCLUDE_DIRS}") -set(_libraries "${HDF5_LIBRARIES};${HDF5_HL_LIBRARIES}") +set(_libraries_tmp "${HDF5_LIBRARIES};${HDF5_HL_LIBRARIES}") + +# HDF5_LIBRARIES and HDF5_HL_LIBRARIES might contain targets or full paths to libraries +# try to find full paths in the former case +set(_libraries) +foreach(_library ${_libraries_tmp}) + if(TARGET ${_library}) + get_target_property(_configurations ${_library} IMPORTED_CONFIGURATIONS) + if(_configurations) + foreach(_configuration ${_configurations}) + get_target_property(_imported_location ${_library} IMPORTED_LOCATION_${_configuration}) + list(APPEND _libraries ${_imported_location}) + endforeach() + else() + get_target_property(_imported_location ${_library} IMPORTED_LOCATION) + list(APPEND _libraries ${_imported_location}) + endif() + else() + list(APPEND _libraries ${_library}) + endif() +endforeach() process_feature(HDF5 LIBRARIES -- 2.39.5