cmake_minimum_required(VERSION 3.2.2)
PROJECT (H4H5_LIB_EXAMPLES C CXX)

#-----------------------------------------------------------------------------
# Build Example
#-----------------------------------------------------------------------------
add_executable (h4toh5example ${H4H5_LIB_EXAMPLES_SOURCE_DIR}/h4toh5example.c)
TARGET_C_PROPERTIES (h4toh5example ${LIB_TYPE} " " " ")
TARGET_NAMING (h4toh5example ${LIB_TYPE})
target_link_libraries (h4toh5example ${H4H5_SRC_LIB_TARGET} ${LINK_LIBS})

#-- Copy all the dat files from the test directory into the source directory
add_custom_command (
     TARGET     h4toh5example
     POST_BUILD
     COMMAND    ${CMAKE_COMMAND}
     ARGS       -E copy_if_different ${H4H5_LIB_EXAMPLES_SOURCE_DIR}/sds_lib_test.hdf "${PROJECT_BINARY_DIR}/sds_lib_test.hdf"
)

if (BUILD_TESTING)
  # Remove any output file left over from previous test run
  add_test (
      NAME h4toh5example-clearall-objects
      COMMAND    ${CMAKE_COMMAND}
          -E remove
          sds_lib_test.h5
  )

  add_test (NAME h4toh5example COMMAND $<TARGET_FILE:h4toh5example>)
  set_tests_properties (h4toh5example PROPERTIES DEPENDS h4toh5example-clearall-objects)
endif ()
