INCLUDE_DIRECTORIES(
  ${HDF5_INCLUDE_DIRS}
  ${MPI_INCLUDE_DIRS}
  ${PROJECT_BINARY_DIR}/include
  ${PROJECT_SOURCE_DIR}/include
)

SET(mdump2_SOURCES 
  mdump2.c 
  MED23meshIterators.c 
  MED23fieldIterators.c
  )
  
SET(mdump3_SOURCES 
  mdump3.c 
  MED23meshIterators.c 
  MED23fieldIterators.c
 )

ADD_EXECUTABLE(mdump2 ${mdump2_SOURCES})
TARGET_LINK_LIBRARIES(mdump2 ${MEDFILE_ENGINE_LIB})

ADD_EXECUTABLE(mdump3 ${mdump3_SOURCES})
TARGET_LINK_LIBRARIES(mdump3 ${MEDFILE_ENGINE_LIB})

INSTALL(TARGETS mdump2 DESTINATION bin)
INSTALL(TARGETS mdump3 DESTINATION bin)

# Configure and install xmdump

SET(prefix ${CMAKE_INSTALL_PREFIX})
CONFIGURE_FILE(xmdump2.in ${PROJECT_BINARY_DIR}/xmdump2 @ONLY)
CONFIGURE_FILE(xmdump3.in ${PROJECT_BINARY_DIR}/xmdump3 @ONLY)

INSTALL(PROGRAMS ${PROJECT_BINARY_DIR}/xmdump2 ${PROJECT_BINARY_DIR}/xmdump3 DESTINATION bin)
INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E create_symlink mdump3 mdump WORKING_DIRECTORY ${DESTDIR}${CMAKE_INSTALL_PREFIX}/bin)")
INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E create_symlink xmdump3 xmdump WORKING_DIRECTORY ${DESTDIR}${CMAKE_INSTALL_PREFIX}/bin)")

