# Create variable so that other source codes can find the include files
set(libtpcimgio_HEADER_FILES "${CMAKE_CURRENT_SOURCE_DIR}" PARENT_SCOPE)

# This needs to be edited each time a new .c is added
add_library (tpcimgio STATIC 
  analyze.c dcm.c ecat63h.c ecat63ml.c ecat63p.c ecat63r.c ecat63w.c
  ecat7h.c ecat7ml.c ecat7p.c ecat7r.c ecat7w.c ecat7ift.c
  img.c imgdecayc.c imgfile.c imgcomp.c imgminmax.c
  imgunits.c img_ana.c img_e63.c img_e7.c img_nii.c
  img_sif.c img_upet.c interfile.c micropet.c
  nifti.c pixel.c sif.c sifio.c ird.c vol.c weight.c
)

# Dependencies on other libraries
include_directories( 
  ${libtpcmisc_HEADER_FILES} 
)
target_link_libraries (tpcimgio tpcmisc m)

# Install the library and headers
install (
  TARGETS tpcimgio
  ARCHIVE 
  DESTINATION ${LIBPATH}
  COMPONENT libraries
)

install (
  FILES libtpcimgio.h 
  DESTINATION ${LIBPATH}/include
  COMPONENT headers
)

# Compile executable(s) for testing
add_executable (libtpcimgio test_libtpcimgio.c) 
add_executable (libtpcimgiobig test_libtpcimgiobig.c) 

# Link the executable to the libraries. 
target_link_libraries (libtpcimgio tpcimgio tpcmisc m)
target_link_libraries (libtpcimgiobig tpcimgio tpcmisc m)

# Copy test data folder
file(COPY test DESTINATION ${CMAKE_CURRENT_BINARY_DIR} )

# Run tests
add_test (
  NAME libtpcimgioTests
  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test
  COMMAND libtpcimgio "--verbose" "--test"
)
add_test (
  NAME libtpcimgiobigTests
  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test
  COMMAND libtpcimgiobig "--verbose" "--test"
)
set_tests_properties(libtpcimgiobigTests PROPERTIES LABELS slow)

