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

# This needs to be edited each time a new .c is added
add_library (tpcextensions STATIC 
  stringext.c decpoint.c filename.c proginfo.c
  units.c statusmsg.c readasciifile.c datetime.c
  doubleutil.c floatutil.c intutil.c endian.c
  studynr.c roiname.c 
)

# Dependencies on other libraries
# Try to keep empty
include_directories(
  $(libtpcextensions_SOURCE_DIR)
  $(libtpcfileutil_HEADER_FILES)
)

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

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

# Compile executable for testing
add_executable (libtpcextensions libtpcextensions.c 
  test_stringext.c test_decpoint.c test_filename.c test_proginfo.c
  test_units.c test_statusmsg.c test_readasciifile.c test_datetime.c
  test_doubleutil.c test_floatutil.c test_intutil.c test_endian.c
  test_studynr.c test_roiname.c
) 
# Link the executable to the libraries. 
target_link_libraries (libtpcextensions tpcextensions m)

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


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

