1 # Don't cache HDF5_*. Otherwise it will use the cached value without searching.
3 unset(HDF5_INCLUDE_DIRS CACHE)
4 unset(HDF5_CXX_LIBRARY_hdf5 CACHE)
5 unset(HDF5_CXX_LIBRARY_hdf5_cpp CACHE)
7 # Case 1. external hdf5
8 if(DEFINED EXT_HDF5_DIR)
9 find_path(HDF5_INCLUDE_DIRS NAMES H5Cpp.h NO_CMAKE_FIND_ROOT_PATH PATHS "${EXT_HDF5_DIR}/include")
10 find_library(HDF5_CXX_LIBRARY_hdf5 NAMES libhdf5.a PATHS "${EXT_HDF5_DIR}/lib")
11 find_library(HDF5_CXX_LIBRARY_hdf5_cpp NAMES libhdf5_cpp.a PATHS "${EXT_HDF5_DIR}/lib")
12 if (NOT (HDF5_INCLUDE_DIRS AND HDF5_CXX_LIBRARY_hdf5 AND HDF5_CXX_LIBRARY_hdf5_cpp))
13 message(WARNING "Failed to find H5Cpp.h or libhdf5.a or libhdf5_cpp.a")
17 # message(FATAL_ERROR "0=${HDF5_INCLUDE_DIRS},1=${HDF5_CXX_LIBRARIES}")
19 list(APPEND HDF5_CXX_LIBRARIES ${HDF5_CXX_LIBRARY_hdf5_cpp} ${HDF5_CXX_LIBRARY_hdf5})
24 # Case 2. search pre-installed locations (by apt, brew, ...)
25 if(NOT CMAKE_CROSSCOMPILING)
26 find_package(HDF5 COMPONENTS CXX QUIET)
28 find_path(HDF5_INCLUDE_DIRS NAMES hdf5.h ONLY_CMAKE_FIND_ROOT_PATH PATH_SUFFIXES include/hdf5/serial)
30 if (NOT HDF5_INCLUDE_DIRS)
35 if(HDF5_USE_STATIC_LIBRARIES)
36 find_library(HDF5_CXX_LIBRARY_hdf5 libhdf5.a)
37 find_library(HDF5_CXX_LIBRARY_hdf5_cpp libhdf5_cpp.a)
38 else(HDF5_USE_STATIC_LIBRARIES)
39 find_library(HDF5_CXX_LIBRARY_hdf5 libhdf5.so)
40 find_library(HDF5_CXX_LIBRARY_hdf5_cpp libhdf5_cpp.so)
41 endif(HDF5_USE_STATIC_LIBRARIES)
43 if (NOT (HDF5_CXX_LIBRARY_hdf5 AND HDF5_CXX_LIBRARY_hdf5_cpp))
48 # We can use "hdf5" and "hdf5_cpp" to use the same file founded with above.
49 list(APPEND HDF5_CXX_LIBRARIES "hdf5" "hdf5_cpp" "sz" "z" "dl" "m")
51 # Append missing libaec which is required by libsz, which is required by libhdf5
52 list(APPEND HDF5_CXX_LIBRARIES "aec")