med: work around "could not find TARGET hdf5" error (#25312)

Fixes #24671, fixes #26051
This commit is contained in:
Christoph Conrads 2021-10-01 16:27:22 +02:00 committed by GitHub
parent c3c28d510f
commit 07e91e8afa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -0,0 +1,13 @@
diff --git a/config/cmake_files/FindMedfileHDF5.cmake b/config/cmake_files/FindMedfileHDF5.cmake
index fbadbf4..5ed78f5 100644
--- a/config/cmake_files/FindMedfileHDF5.cmake
+++ b/config/cmake_files/FindMedfileHDF5.cmake
@@ -115,7 +115,7 @@ IF (HDF5_FOUND)
# HDF5 was compiled with MPI support
# Unfortunately HDF5 doesn't expose its MPI configuration easily ...
# We sniff the properties of the HDF5 target which should also be there:
- GET_PROPERTY(_lib_lst TARGET hdf5 PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES_NOCONFIG)
+ GET_PROPERTY(_lib_lst TARGET hdf5-shared PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES_NOCONFIG)
FOREACH(s ${_lib_lst})
STRING(FIND "${s}" "mpi." _res) # should cover WIN(?) and LINUX
IF(_res GREATER -1)

View File

@ -30,11 +30,15 @@ class Med(CMakePackage):
depends_on('hdf5@1.10.2:1.10.7+mpi', when='@4.0.0:+mpi')
depends_on('hdf5@:1.8.22~mpi', when='@3.2.0~mpi')
depends_on('hdf5@1.10.2:1.10.7~mpi', when='@4.0.0:~mpi')
# the "TARGET hdf5" patch below only works with HDF5 shared library builds
depends_on('hdf5+shared', when='@4.0.0:4.1.99')
conflicts("@4.1.0", when="~shared", msg="Link error when static")
# C++11 requires a space between literal and identifier
patch('add_space.patch', when='@3.2.0')
# fix problem where CMake "could not find TARGET hdf5"
patch('med-4.1.0-hdf5-target.patch', when='@4.0.0:4.1.99')
def cmake_args(self):
spec = self.spec