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

# This needs to be edited each time a new .c is added
add_library (tpcmisc STATIC 
  backup.c branch.c datetime.c decpoint.c doubleutil.c 
  filename.c halflife.c idcrypt.c ift.c iftfile.c 
  iftsrch.c intex.c petc99.c petunits.c proginfo.c 
  quots.c readfile.c rname.c strext.c studynr.c swap.c
)

# Dependencies on other libraries
# none so far, and keep it that way

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

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

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

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

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

