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

# This needs to be edited each time a new .c is added
add_library (tpcsvg STATIC 
  axis.c svg_defs.c svg_file.c svg_legend.c
  svg_plot.c svg_title.c svg_vport.c
)

# Dependencies on other libraries (do not add any libraries from v1 or v2)
target_link_libraries (tpcsvg
  m
)

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

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

# Dependencies of executable on other libraries
include_directories( ${libtpcmisc_HEADER_FILES} )
# Compile executable for testing
add_executable (libtpcsvg test_libtpcsvg.c) 
# Link the executable to the libraries. 
target_link_libraries (libtpcsvg tpcsvg tpcmisc m)
# Install the executable
#INSTALL(
#  PROGRAMS 
#  ${CMAKE_CURRENT_BINARY_DIR}/libtpcsvg${CMAKE_EXECUTABLE_SUFFIX}
#  DESTINATION bin
#  COMPONENT librarytests
#)

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

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

