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 if(NOT BUILD_WITH_HDF5)
10 endif(NOT BUILD_WITH_HDF5)
12 # Case 1. external hdf5
13 if(DEFINED EXT_HDF5_DIR)
14 find_path(HDF5_INCLUDE_DIRS NAMES H5Cpp.h NO_CMAKE_FIND_ROOT_PATH PATHS "${EXT_HDF5_DIR}/include")
15 find_library(HDF5_CXX_LIBRARY_hdf5 NAMES libhdf5.a PATHS "${EXT_HDF5_DIR}/lib")
16 find_library(HDF5_CXX_LIBRARY_hdf5_cpp NAMES libhdf5_cpp.a PATHS "${EXT_HDF5_DIR}/lib")
17 if (NOT (HDF5_INCLUDE_DIRS AND HDF5_CXX_LIBRARY_hdf5 AND HDF5_CXX_LIBRARY_hdf5_cpp))
18 message(WARNING "Failed to find H5Cpp.h or libhdf5.a or libhdf5_cpp.a")
22 # message(FATAL_ERROR "0=${HDF5_INCLUDE_DIRS},1=${HDF5_CXX_LIBRARIES}")
24 list(APPEND HDF5_CXX_LIBRARIES ${HDF5_CXX_LIBRARY_hdf5_cpp} ${HDF5_CXX_LIBRARY_hdf5})
29 # Case 2. search pre-installed locations (by apt, brew, ...)
30 if(NOT CMAKE_CROSSCOMPILING)
31 find_package(HDF5 COMPONENTS CXX QUIET)
33 find_path(HDF5_INCLUDE_DIRS NAMES hdf5.h ONLY_CMAKE_FIND_ROOT_PATH PATH_SUFFIXES include/hdf5/serial)
35 if (NOT HDF5_INCLUDE_DIRS)
40 if(HDF5_USE_STATIC_LIBRARIES)
41 find_library(HDF5_CXX_LIBRARY_hdf5 libhdf5.a)
42 find_library(HDF5_CXX_LIBRARY_hdf5_cpp libhdf5_cpp.a)
43 else(HDF5_USE_STATIC_LIBRARIES)
44 find_library(HDF5_CXX_LIBRARY_hdf5 libhdf5.so)
45 find_library(HDF5_CXX_LIBRARY_hdf5_cpp libhdf5_cpp.so)
46 endif(HDF5_USE_STATIC_LIBRARIES)
48 if (NOT (HDF5_CXX_LIBRARY_hdf5 AND HDF5_CXX_LIBRARY_hdf5_cpp))
53 # We can use "hdf5" and "hdf5_cpp" to use the same file founded with above.
54 list(APPEND HDF5_CXX_LIBRARIES "hdf5" "hdf5_cpp" "sz" "z" "dl" "m")
56 # Append missing libaec which is required by libsz, which is required by libhdf5
57 list(APPEND HDF5_CXX_LIBRARIES "aec")