# Set up HDF5 library

# Summary of CMake flags and compile definitions:
#
# CMake flags:
#   HDF5_CXX_INCLUDE_DIRS: directory of HDF5 c++ headers
#   HDF5_CXX_LIBRARIES: HDF5 c++ libraries
#
# Compile definitions:
#   WITH_HDF5: whether to enable HDF5 support
#   HDF5_CXX_DEFINITION: definitions made by HDF5 library itself

find_package(HDF5 REQUIRED COMPONENTS CXX)

# Compile definitions and header directories should be defined PUBLIC,
# otherwise there may be inconsistencies in headers, especially for C++
# which uses templates.
function(tbp_set_hdf5 arg)
    target_compile_definitions(${arg} PUBLIC WITH_HDF5)
    target_compile_definitions(${arg} PUBLIC ${HDF5_CXX_DEFINITION})
    target_include_directories(${arg} PUBLIC ${HDF5_CXX_INCLUDE_DIRS})
    target_link_libraries(${arg} PUBLIC ${HDF5_CXX_LIBRARIES})
endfunction()
