@@ -157,7 +157,7 @@ message(DEBUG "HDF5 version match 0, 1: ${CMAKE_MATCH_0} ${CMAKE_MATCH_1}")
157
157
158
158
# avoid picking up incompatible zlib over the desired zlib
159
159
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 )
161
161
list (APPEND ZLIB_ROOT ${HDF5_ROOT} )
162
162
endif ()
163
163
@@ -226,6 +226,8 @@ endif()
226
226
227
227
hdf5_fortran_wrap (hdf5_lib_dirs hdf5_inc_dirs )
228
228
229
+ # "PATH" Env var is useful on HPC for finding HDF5 libraries
230
+
229
231
if (MSVC )
230
232
set (CMAKE_FIND_LIBRARY_PREFIXES lib )
231
233
endif ()
@@ -236,7 +238,7 @@ set(_hl_stub_names hdf5_hl_f90cstub)
236
238
set (_stub_names hdf5_f90cstub )
237
239
238
240
# distro names (Ubuntu)
239
- if (parallel IN_LIST HDF5_FIND_COMPONENTS )
241
+ if (HDF5_parallel_FOUND )
240
242
list (APPEND _names hdf5_openmpi_fortran hdf5_mpich_fortran )
241
243
list (APPEND _hl_names hdf5_openmpihl_fortran hdf5_mpichhl_fortran )
242
244
else ()
@@ -265,28 +267,27 @@ NAMES_PER_DIR
265
267
DOC "HDF5 Fortran API"
266
268
)
267
269
270
+ cmake_path (GET HDF5_Fortran_LIBRARY PARENT_PATH hdf5_libdir )
271
+
268
272
find_library (HDF5_Fortran_HL_LIBRARY
269
273
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
273
276
DOC "HDF5 Fortran HL high-level API"
274
277
)
275
278
276
279
# not all platforms have this stub
277
280
find_library (HDF5_Fortran_HL_stub
278
281
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
282
284
DOC "Fortran C HL interface, not all HDF5 implementations have/need this"
283
285
)
284
286
285
287
find_library (HDF5_Fortran_stub
286
288
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
290
291
DOC "Fortran C interface, not all HDF5 implementations have/need this"
291
292
)
292
293
@@ -303,7 +304,7 @@ if(HDF5_ROOT)
303
304
DOC "HDF5 Fortran module path"
304
305
)
305
306
else ()
306
- if (parallel IN_LIST HDF5_FIND_COMPONENTS )
307
+ if (HDF5_parallel_FOUND )
307
308
# HDF5-MPI system library presents a unique challenge, as when non-MPI HDF5 is
308
309
# also installed, which is typically necessary for other system libraries, the
309
310
# HDF5-MPI compiler wrapper often includes that wrong non-MPI include dir first.
@@ -362,8 +363,15 @@ endfunction(find_hdf5_fortran)
362
363
363
364
function (find_hdf5_cxx )
364
365
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
+
365
371
hdf5_cxx_wrap (hdf5_lib_dirs hdf5_inc_dirs )
366
372
373
+ # "PATH" Env var is useful on HPC for finding HDF5 libraries
374
+
367
375
if (MSVC )
368
376
set (CMAKE_FIND_LIBRARY_PREFIXES lib )
369
377
endif ()
@@ -372,7 +380,7 @@ set(_names hdf5_cpp)
372
380
set (_hl_names hdf5_hl_cpp )
373
381
374
382
# distro names (Ubuntu)
375
- if (parallel IN_LIST HDF5_FIND_COMPONENTS )
383
+ if (HDF5_parallel_FOUND )
376
384
list (APPEND _names hdf5_openmpi_cpp hdf5_mpich_cpp )
377
385
list (APPEND _hl_names hdf5_openmpi_hl_cpp hdf5_mpich_hl_cpp )
378
386
else ()
@@ -397,11 +405,12 @@ NAMES_PER_DIR
397
405
DOC "HDF5 C++ API"
398
406
)
399
407
408
+ cmake_path (GET HDF5_CXX_LIBRARY PARENT_PATH hdf5_libdir )
409
+
400
410
find_library (HDF5_CXX_HL_LIBRARY
401
411
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
405
414
DOC "HDF5 C++ high-level API"
406
415
)
407
416
@@ -425,6 +434,8 @@ function(find_hdf5_c)
425
434
426
435
hdf5_c_wrap (hdf5_lib_dirs hdf5_inc_dirs )
427
436
437
+ # "PATH" Env var is useful on HPC for finding HDF5 libraries
438
+
428
439
if (MSVC )
429
440
set (CMAKE_FIND_LIBRARY_PREFIXES lib )
430
441
endif ()
@@ -459,11 +470,12 @@ NAMES_PER_DIR
459
470
DOC "HDF5 C library (necessary for all languages)"
460
471
)
461
472
473
+ cmake_path (GET HDF5_C_LIBRARY PARENT_PATH hdf5_libdir )
474
+
462
475
find_library (HDF5_C_HL_LIBRARY
463
476
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
467
479
DOC "HDF5 C high level interface"
468
480
)
469
481
@@ -488,7 +500,7 @@ function(hdf5_fortran_wrap lib_var inc_var)
488
500
set (lib_dirs )
489
501
set (inc_dirs )
490
502
491
- if (parallel IN_LIST HDF5_FIND_COMPONENTS )
503
+ if (HDF5_parallel_FOUND )
492
504
set (wrapper_names h5pfc h5pfc.openmpi h5pfc.mpich )
493
505
else ()
494
506
set (wrapper_names h5fc )
@@ -545,7 +557,7 @@ function(hdf5_cxx_wrap lib_var inc_var)
545
557
set (lib_dirs )
546
558
set (inc_dirs )
547
559
548
- if (parallel IN_LIST HDF5_FIND_COMPONENTS )
560
+ if (HDF5_parallel_FOUND )
549
561
set (wrapper_names h5c++.openmpi h5c++.mpich )
550
562
else ()
551
563
set (wrapper_names h5c++ )
@@ -743,10 +755,10 @@ endfunction(check_fortran_links)
743
755
744
756
function (check_hdf5_link )
745
757
746
- # HDF5 bug #3663 for HDF5 1.14.2, 1.14.3, ...?
758
+ # HDF5 bug #3663 for HDF5 1.14.2, ...?
747
759
# https://github.com/HDFGroup/hdf5/issues/3663
748
760
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 ]" )
750
762
message (VERBOSE "FindHDF5: applying workaround for HDF5 bug #3663 with Intel oneAPI on Windows" )
751
763
list (APPEND CMAKE_REQUIRED_LIBRARIES shlwapi )
752
764
endif ()
0 commit comments