File: FindHDF5.cmake

package info (click to toggle)
coda 2.25.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,008 kB
  • sloc: ansic: 121,488; javascript: 6,788; java: 2,369; python: 1,695; yacc: 1,007; makefile: 598; lex: 204; sh: 105; fortran: 60; xml: 5
file content (45 lines) | stat: -rw-r--r-- 1,500 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Find the HDF5 library
#
# This module defines
# HDF5_INCLUDE_DIR, where to find hdf5.h, etc.
# HDF5_LIBRARIES, the hdf5 libraries to link against to use HDF5.
# HDF5_FOUND, If false, do not try to use HDF5.
#
# The user may specify HDF5_INCLUDE_DIR and HDF5_LIBRARY_DIR variables
# to locate include and library files
#
include(CheckLibraryExists)
include(CheckIncludeFile)

set(HDF5_INCLUDE_DIR CACHE STRING "Location of HDF5 include files")
set(HDF5_LIBRARY_DIR CACHE STRING "Location of HDF5 library files")

find_package(ZLIB)
find_package(SZIP)

if(HDF5_INCLUDE_DIR)
  set(CMAKE_REQUIRED_INCLUDES ${HDF5_INCLUDE_DIR})
endif(HDF5_INCLUDE_DIR)

check_include_file(hdf5.h HAVE_HDF5_H)

find_library(HDF5_LIBRARY NAMES hdf5 libhdf5 PATHS ${HDF5_LIBRARY_DIR})
if(HDF5_LIBRARY)
  set(CMAKE_REQUIRED_LIBRARIES ${ZLIB_LIBRARIES} ${SZIP_LIBRARIES})
  check_library_exists(${HDF5_LIBRARY} H5Fopen "" HAVE_HDF5_LIBRARY)
endif(HDF5_LIBRARY)

if(HAVE_HDF5_LIBRARY)
  set(HDF5_LIBRARIES ${HDF5_LIBRARY} ${ZLIB_LIBRARIES} ${SZIP_LIBRARIES})
endif(HAVE_HDF5_LIBRARY)

if(WIN32 AND HAVE_HDF5_LIBRARY)
get_filename_component(HDF5_LIBRARY_NAME ${HDF5_LIBRARY} NAME_WE)
find_file(HDF5_DLL NAMES ${HDF5_LIBRARY_NAME}.dll PATHS ${HDF5_LIBRARY_DIR} ${HDF5_LIBRARY_DIR}/../bin)
if(HDF5_DLL)
set(HDF5_DLLS ${HDF5_DLL} ${ZLIB_DLLS} ${SZIP_DLLS})
endif(HDF5_DLL)
endif(WIN32 AND HAVE_HDF5_LIBRARY)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(HDF5 DEFAULT_MSG HAVE_HDF5_LIBRARY HAVE_HDF5_H)