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

# This needs to be edited each time a new .c is added
add_library (tpcabss STATIC 
  abss.c abssio.c
)
# Dependencies on other libraries
include_directories(
#  $(libtpcabss_SOURCE_DIR)
  ${libtpcextensions_HEADER_FILES}
  ${libtpcift_HEADER_FILES}
  ${libtpccsv_HEADER_FILES}
  ${libtpcisotope_HEADER_FILES}
  ${libtpctac_HEADER_FILES}
)
target_link_libraries (
  tpcabss 
  tpctac tpcift tpccsv tpcextensions 
  m
)

# Install the library and headers
install (
  TARGETS tpcabss
  ARCHIVE 
  DESTINATION ${LIBPATH}
  COMPONENT libraries
)
install (
  FILES tpcabss.h 
  DESTINATION ${LIBPATH}/include
  COMPONENT headers
)

# Compile executable for testing
add_executable (libtpcabss libtpcabss.c 
  test_abss.c test_abssio.c
) 
# Link the executable to the libraries. 
target_link_libraries (
  libtpcabss tpcabss 
  tpctac tpcift tpccsv tpcextensions 
  m
)
# Install the executable
#install(
#  PROGRAMS 
#  ${CMAKE_CURRENT_BINARY_DIR}/libtpcabss${CMAKE_EXECUTABLE_SUFFIX}
#  DESTINATION bin
#  COMPONENT librarytests
#)

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

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