Skip to content

Commit b87e64a

Browse files
committed
HDF5 1.14.4.3, Zlib 2.2.1, FindHDF5 efficiency
1 parent dbfda2d commit b87e64a

File tree

2 files changed

+37
-25
lines changed

2 files changed

+37
-25
lines changed

cmake/FindHDF5.cmake

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ message(DEBUG "HDF5 version match 0, 1: ${CMAKE_MATCH_0} ${CMAKE_MATCH_1}")
157157

158158
# avoid picking up incompatible zlib over the desired zlib
159159
if(NOT ZLIB_ROOT)
160-
get_filename_component(ZLIB_ROOT ${HDF5_C_INCLUDE_DIR} DIRECTORY)
160+
cmake_path(GET HDF5_C_INCLUDE_DIR PARENT_PATH ZLIB_ROOT)
161161
list(APPEND ZLIB_ROOT ${HDF5_ROOT})
162162
endif()
163163

@@ -226,6 +226,8 @@ endif()
226226

227227
hdf5_fortran_wrap(hdf5_lib_dirs hdf5_inc_dirs)
228228

229+
# "PATH" Env var is useful on HPC for finding HDF5 libraries
230+
229231
if(MSVC)
230232
set(CMAKE_FIND_LIBRARY_PREFIXES lib)
231233
endif()
@@ -236,7 +238,7 @@ set(_hl_stub_names hdf5_hl_f90cstub)
236238
set(_stub_names hdf5_f90cstub)
237239

238240
# distro names (Ubuntu)
239-
if(parallel IN_LIST HDF5_FIND_COMPONENTS)
241+
if(HDF5_parallel_FOUND)
240242
list(APPEND _names hdf5_openmpi_fortran hdf5_mpich_fortran)
241243
list(APPEND _hl_names hdf5_openmpihl_fortran hdf5_mpichhl_fortran)
242244
else()
@@ -265,28 +267,27 @@ NAMES_PER_DIR
265267
DOC "HDF5 Fortran API"
266268
)
267269

270+
cmake_path(GET HDF5_Fortran_LIBRARY PARENT_PATH hdf5_libdir)
271+
268272
find_library(HDF5_Fortran_HL_LIBRARY
269273
NAMES ${_hl_names}
270-
HINTS ${HDF5_ROOT} ${hdf5_lib_dirs}
271-
PATH_SUFFIXES ${hdf5_lsuf}
272-
NAMES_PER_DIR
274+
HINTS ${hdf5_libdir}
275+
NO_DEFAULT_PATH
273276
DOC "HDF5 Fortran HL high-level API"
274277
)
275278

276279
# not all platforms have this stub
277280
find_library(HDF5_Fortran_HL_stub
278281
NAMES ${_hl_stub_names}
279-
HINTS ${HDF5_ROOT} ${hdf5_lib_dirs}
280-
PATH_SUFFIXES ${hdf5_lsuf}
281-
NAMES_PER_DIR
282+
HINTS ${hdf5_libdir}
283+
NO_DEFAULT_PATH
282284
DOC "Fortran C HL interface, not all HDF5 implementations have/need this"
283285
)
284286

285287
find_library(HDF5_Fortran_stub
286288
NAMES ${_stub_names}
287-
HINTS ${HDF5_ROOT} ${hdf5_lib_dirs}
288-
PATH_SUFFIXES ${hdf5_lsuf}
289-
NAMES_PER_DIR
289+
HINTS ${hdf5_libdir}
290+
NO_DEFAULT_PATH
290291
DOC "Fortran C interface, not all HDF5 implementations have/need this"
291292
)
292293

@@ -303,7 +304,7 @@ if(HDF5_ROOT)
303304
DOC "HDF5 Fortran module path"
304305
)
305306
else()
306-
if(parallel IN_LIST HDF5_FIND_COMPONENTS)
307+
if(HDF5_parallel_FOUND)
307308
# HDF5-MPI system library presents a unique challenge, as when non-MPI HDF5 is
308309
# also installed, which is typically necessary for other system libraries, the
309310
# HDF5-MPI compiler wrapper often includes that wrong non-MPI include dir first.
@@ -362,8 +363,15 @@ endfunction(find_hdf5_fortran)
362363

363364
function(find_hdf5_cxx)
364365

366+
if(parallel IN_LIST HDF5_FIND_COMPONENTS AND NOT HDF5_parallel_FOUND)
367+
# avoid expensive C++ find when MPI isn't linked properly
368+
return()
369+
endif()
370+
365371
hdf5_cxx_wrap(hdf5_lib_dirs hdf5_inc_dirs)
366372

373+
# "PATH" Env var is useful on HPC for finding HDF5 libraries
374+
367375
if(MSVC)
368376
set(CMAKE_FIND_LIBRARY_PREFIXES lib)
369377
endif()
@@ -372,7 +380,7 @@ set(_names hdf5_cpp)
372380
set(_hl_names hdf5_hl_cpp)
373381

374382
# distro names (Ubuntu)
375-
if(parallel IN_LIST HDF5_FIND_COMPONENTS)
383+
if(HDF5_parallel_FOUND)
376384
list(APPEND _names hdf5_openmpi_cpp hdf5_mpich_cpp)
377385
list(APPEND _hl_names hdf5_openmpi_hl_cpp hdf5_mpich_hl_cpp)
378386
else()
@@ -397,11 +405,12 @@ NAMES_PER_DIR
397405
DOC "HDF5 C++ API"
398406
)
399407

408+
cmake_path(GET HDF5_CXX_LIBRARY PARENT_PATH hdf5_libdir)
409+
400410
find_library(HDF5_CXX_HL_LIBRARY
401411
NAMES ${_hl_names}
402-
HINTS ${HDF5_ROOT} ${hdf5_lib_dirs}
403-
PATH_SUFFIXES ${hdf5_lsuf}
404-
NAMES_PER_DIR
412+
HINTS ${hdf5_libdir}
413+
NO_DEFAULT_PATH
405414
DOC "HDF5 C++ high-level API"
406415
)
407416

@@ -425,6 +434,8 @@ function(find_hdf5_c)
425434

426435
hdf5_c_wrap(hdf5_lib_dirs hdf5_inc_dirs)
427436

437+
# "PATH" Env var is useful on HPC for finding HDF5 libraries
438+
428439
if(MSVC)
429440
set(CMAKE_FIND_LIBRARY_PREFIXES lib)
430441
endif()
@@ -459,11 +470,12 @@ NAMES_PER_DIR
459470
DOC "HDF5 C library (necessary for all languages)"
460471
)
461472

473+
cmake_path(GET HDF5_C_LIBRARY PARENT_PATH hdf5_libdir)
474+
462475
find_library(HDF5_C_HL_LIBRARY
463476
NAMES ${_hl_names}
464-
HINTS ${HDF5_ROOT} ${hdf5_lib_dirs}
465-
PATH_SUFFIXES ${hdf5_lsuf}
466-
NAMES_PER_DIR
477+
HINTS ${hdf5_libdir}
478+
NO_DEFAULT_PATH
467479
DOC "HDF5 C high level interface"
468480
)
469481

@@ -488,7 +500,7 @@ function(hdf5_fortran_wrap lib_var inc_var)
488500
set(lib_dirs)
489501
set(inc_dirs)
490502

491-
if(parallel IN_LIST HDF5_FIND_COMPONENTS)
503+
if(HDF5_parallel_FOUND)
492504
set(wrapper_names h5pfc h5pfc.openmpi h5pfc.mpich)
493505
else()
494506
set(wrapper_names h5fc)
@@ -545,7 +557,7 @@ function(hdf5_cxx_wrap lib_var inc_var)
545557
set(lib_dirs)
546558
set(inc_dirs)
547559

548-
if(parallel IN_LIST HDF5_FIND_COMPONENTS)
560+
if(HDF5_parallel_FOUND)
549561
set(wrapper_names h5c++.openmpi h5c++.mpich)
550562
else()
551563
set(wrapper_names h5c++)
@@ -743,10 +755,10 @@ endfunction(check_fortran_links)
743755

744756
function(check_hdf5_link)
745757

746-
# HDF5 bug #3663 for HDF5 1.14.2, 1.14.3, ...?
758+
# HDF5 bug #3663 for HDF5 1.14.2, ...?
747759
# https://github.com/HDFGroup/hdf5/issues/3663
748760
if(WIN32 AND CMAKE_Fortran_COMPILER_ID MATCHES "^Intel")
749-
if(HDF5_VERSION MATCHES "1.14.[2-3]")
761+
if(HDF5_VERSION MATCHES "1.14.[2-4]")
750762
message(VERBOSE "FindHDF5: applying workaround for HDF5 bug #3663 with Intel oneAPI on Windows")
751763
list(APPEND CMAKE_REQUIRED_LIBRARIES shlwapi)
752764
endif()

cmake/libraries.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"zlib": {
33
"url" : "https://github.com/zlib-ng/zlib-ng.git",
4-
"tag": "2.1.6"
4+
"tag": "2.2.1"
55
},
66
"hdf5": {
7-
"url": "https://github.com/HDFGroup/hdf5/releases/download/hdf5_1.14.4.2/hdf5-1.14.4-2.tar.gz"
7+
"url": "https://github.com/HDFGroup/hdf5/releases/download/hdf5_1.14.4.3/hdf5_1.14.4.3.tar.gz"
88
}
99
}

0 commit comments

Comments
 (0)