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

# This needs to be edited each time a new .c is added
add_library (tpccurveio STATIC 
  cpt.c csv.c dft.c dftdecayc.c dftio.c
  dftres.c dftunit.c fitres.c idwc.c if.c
  mathfunc.c ncifile.c resift.c result.c tsv.c 
  xeleris.c 
)

# Dependencies on other libraries
include_directories( ${libtpcmisc_HEADER_FILES} )
include_directories( ${libtpcmodel_HEADER_FILES} )
target_link_libraries (tpccurveio tpcmodel tpcmisc m)

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

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

# Compile executable for testing
add_executable (libtpccurveio test_libtpccurveio.c) 
# Link the executable to the libraries. 
target_link_libraries (libtpccurveio tpccurveio tpcmisc m)
# Install the executable
#install (
#  PROGRAMS 
#  ${CMAKE_CURRENT_BINARY_DIR}/libtpccurveio${CMAKE_EXECUTABLE_SUFFIX}
#  DESTINATION bin
#  COMPONENT librarytests
#)

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

# Run tests
add_test (
  NAME libtpccurveioTests 
  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test
  COMMAND libtpccurveio "--verbose" "--test"
)

