find_package(Eigen3 REQUIRED)
find_package(HDF5 REQUIRED COMPONENTS C)
# Add as "system headers" to avoid warnings generated by them with
# compilers that support that notion.
include_directories(SYSTEM "${EIGEN3_INCLUDE_DIR}"
  "${HDF5_INCLUDE_DIRS}"
  "${AvogadroLibs_SOURCE_DIR}/thirdparty/pugixml"
  "${AvogadroLibs_SOURCE_DIR}/thirdparty/jsoncpp")

if(DEFINED AvogadroLibs_MEMORY_INCLUDE_DIRS)
  # The smart pointer classes just require headers.
  include_directories(SYSTEM ${AvogadroLibs_MEMORY_INCLUDE_DIRS})
endif()

set(HEADERS
  cjsonformat.h
  cmlformat.h
  fileformat.h
  fileformatmanager.h
  gromacsformat.h
  hdf5dataformat.h
  mdlformat.h
  xyzformat.h
)

set(SOURCES
  cjsonformat.cpp
  cmlformat.cpp
  fileformat.cpp
  fileformatmanager.cpp
  gromacsformat.cpp
  hdf5dataformat.cpp
  mdlformat.cpp
  xyzformat.cpp
)

avogadro_add_library(AvogadroIO ${HEADERS} ${SOURCES})

# hdf5 is the HDF5 imported target
target_link_libraries(AvogadroIO LINK_PUBLIC AvogadroCore LINK_PRIVATE hdf5)

find_package(Eigen3 REQUIRED)
find_package(HDF5 REQUIRED COMPONENTS C)
# Add as "system headers" to avoid warnings generated by them with
# compilers that support that notion.
include_directories(SYSTEM "${EIGEN3_INCLUDE_DIR}"
  "${HDF5_INCLUDE_DIRS}"
  "${AvogadroLibs_SOURCE_DIR}/thirdparty/pugixml"
  "${AvogadroLibs_SOURCE_DIR}/thirdparty/jsoncpp")

if(DEFINED AvogadroLibs_MEMORY_INCLUDE_DIRS)
  # The smart pointer classes just require headers.
  include_directories(SYSTEM ${AvogadroLibs_MEMORY_INCLUDE_DIRS})
endif()

set(HEADERS
  cjsonformat.h
  cmlformat.h
  fileformat.h
  fileformatmanager.h
  gromacsformat.h
  hdf5dataformat.h
  mdlformat.h
  xyzformat.h
)

set(SOURCES
  cjsonformat.cpp
  cmlformat.cpp
  fileformat.cpp
  fileformatmanager.cpp
  gromacsformat.cpp
  hdf5dataformat.cpp
  mdlformat.cpp
  xyzformat.cpp
)

avogadro_add_library(AvogadroIO ${HEADERS} ${SOURCES})

# HDF5 library paths provided by find module
target_link_libraries(AvogadroIO LINK_PUBLIC AvogadroCore LINK_PRIVATE ${HDF5_LIBRARIES})

Fix linking to HDF5 libraries.
Fix linking to HDF5 libraries.

Use library paths as provided by CMake's find module to correctly find
shared library in subdirectories, e.g.:
/usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.so
