set(PACKAGE base-fileformats)

message(STATUS ${PACKAGE})

set(APP_NAME unit_test)
set(LIB_NAME fileformats)
set(INST_INCLUDES fileformats_lib.h)

include_directories(
  ${CMAKE_CURRENT_SOURCE_DIR}/../include
  ${CMAKE_CURRENT_SOURCE_DIR}/../user_lib
  ${CMAKE_CURRENT_SOURCE_DIR}/../himath_lib)

set(SOURCE_FILES
    read_gif.c
    read_jpeg.c
    read_tiff.c
    read_pbm.c
    read_picfile.c
    write_bmp.c
    write_gif.c
    write_jpeg.c
    write_png.c
    write_tiff.c
    write_ps.c
    write_file_format.c
    ColormapFromRgb.c
    conv24to8.c
    printer_func.c
    fileformats_lib.h
    fileformats.h)

link_libraries(
  user
  jpeg
  png
  tiff
  geotiff
  m
  himath)

add_library(${LIB_NAME} SHARED ${SOURCE_FILES})

set(LIB_MAJOR_VER 10) # Set Library major version, this is also used for SO file versioning
set(LIB_MINOR_VER 0) # Set Library minor version
set(LIB_PATCH_VER 0) # Set Library patch version
set(LIB_VERSION "${LIB_MAJOR_VER}.${LIB_MINOR_VER}.${LIB_PATCH_VER}")
set_target_properties(${LIB_NAME} PROPERTIES VERSION ${LIB_VERSION} SOVERSION ${LIB_MAJOR_VER})

add_executable(${APP_NAME} ${SOURCE_FILES} unit_test.c)

install(
  TARGETS ${LIB_NAME}
  DESTINATION ${IRIS_LIB}
  LIBRARY COMPONENT base NAMELINK_COMPONENT devel)
  
install(
  FILES ${INST_INCLUDES}
  DESTINATION ${IRIS_INCLUDE}
  COMPONENT devel)
