|
1 | 1 | # don't enclose this all in "if(NOT DEFINED HDF5OK)" because CMake intermittantly doesn't cache needed HDF5 variables. |
2 | 2 |
|
3 | 3 | set(HDF5_USE_STATIC_LIBRARIES true) |
4 | | - |
5 | 4 | # Intel HDF5 for Windows has some real issues from the factory, this makes it work: |
6 | 5 | if(WIN32 AND CMAKE_Fortran_COMPILER_ID STREQUAL Intel) |
7 | 6 | set(HDF5_NO_FIND_PACKAGE_CONFIG_FILE true) |
8 | | - set(HDF5_SEARCH_WRAPPER false) |
9 | 7 | set(HDF5_USE_STATIC_LIBRARIES false) |
10 | 8 | endif() |
11 | 9 |
|
12 | 10 | find_package(HDF5 REQUIRED COMPONENTS Fortran HL) |
13 | | -if(MINGW) |
14 | | - set(HDF5_INCLUDE_DIRS ${HDF5_INCLUDE_DIRS}/static) |
| 11 | +list(APPEND HDF5_INCLUDE_DIRS ${HDF5_Fortran_INCLUDE_DIRS}) |
| 12 | +# this is because HDF5's CONFIG files are incorrect (at least for 1.10.5) |
| 13 | +find_path(HDF5_MODULE_DIR NAMES hdf5.mod HINTS ${HDF5_INCLUDE_DIRS} PATH_SUFFIXES static) |
| 14 | +if(HDF5_MODULE_DIR) |
| 15 | + list(APPEND HDF5_INCLUDE_DIRS ${HDF5_MODULE_DIR}) |
| 16 | + set(SZIP_ROOT "${HDF5_MODULE_DIR}/..;${HDF5_MODULE_DIR}/../..") |
| 17 | + set(ZLIB_ROOT ${SZIP_ROOT}) |
15 | 18 | endif() |
| 19 | +list(REMOVE_DUPLICATES HDF5_INCLUDE_DIRS) |
16 | 20 |
|
| 21 | +# in case the compiler wrapper didn't work |
17 | 22 | set(HDF5_LIBRARIES ${HDF5_Fortran_HL_LIBRARIES} ${HDF5_Fortran_LIBRARIES} ${HDF5_LIBRARIES}) |
18 | | -list(APPEND HDF5_INCLUDE_DIRS ${HDF5_Fortran_INCLUDE_DIRS}) |
| 23 | + |
| 24 | +find_package(SZIP) |
| 25 | +if(SZIP_FOUND) |
| 26 | + list(APPEND HDF5_LIBRARIES SZIP::SZIP) |
| 27 | +endif() |
| 28 | +find_package(ZLIB) |
| 29 | +if(ZLIB_FOUND) |
| 30 | + list(APPEND HDF5_LIBRARIES ZLIB::ZLIB) |
| 31 | +endif() |
| 32 | +set(THREADS_PREFER_PTHREAD_FLAG true) |
| 33 | +find_package(Threads) |
| 34 | +if(Threads_FOUND) |
| 35 | + list(APPEND HDF5_LIBRARIES Threads::Threads) |
| 36 | +endif() |
| 37 | +list(APPEND HDF5_LIBRARIES ${CMAKE_DL_LIBS}) |
| 38 | +if(UNIX) |
| 39 | + list(APPEND HDF5_LIBRARIES m) |
| 40 | +endif() |
19 | 41 |
|
20 | 42 | if(DEFINED HDF5OK) |
21 | 43 | return() |
22 | 44 | endif() |
23 | 45 |
|
24 | 46 | message(STATUS "HDF5 include: ${HDF5_INCLUDE_DIRS}") |
25 | 47 | message(STATUS "HDF5 library: ${HDF5_LIBRARIES}") |
| 48 | +# we don't use these because they may come from a broken compiler wrapper |
26 | 49 | if(HDF5_Fortran_COMPILER_EXECUTABLE) |
27 | 50 | message(STATUS "HDF5 Fortran compiler: ${HDF5_Fortran_COMPILER_EXECUTABLE}") |
28 | 51 | endif() |
|
0 commit comments