set(PACKAGE base-rscan_lib)

message(STATUS ${PACKAGE})

list(
  APPEND
  INST_INCLUDES
  archive2_io.h
  config_set.h
  nav_system.h
  radar_ray.h
  radar_sweep.h
  radar_scan.h
  rawprod_io.h
  rscan_prod_io.h)
set(LIB_NAME rscan)

set(SOURCE_FILES
    timeval_ops.h
    config_set.h
    i16stream.h
    nav_system.h
    radar_ray.h
    radar_sweep.h
    radar_scan.h
    rawprod_io.h
    rscan_prod_io.h
    archive2_io.h
    nav_system.c
    config_set.c
    radar_ray.c
    radar_sweep.c
    radar_scan.c
    i16stream.c
    rawprod_io.c
    rscan_prod_io.c
    archive2_io.c)

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})

target_include_directories(
  ${LIB_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
                     ${CMAKE_CURRENT_SOURCE_DIR}/../dsp_lib
                     ${CMAKE_CURRENT_SOURCE_DIR}/../user_lib
                     ${CMAKE_CURRENT_SOURCE_DIR}/../include)

# TODO: rscan should not require "user dsp antenna config exthdr dl z" libs The
# antenna, z, and config are pulled in by dsp
link_libraries(
  rscan
  user
  dsp
  antenna
  config
  exthdr
  dl
  z
  m
  popt)

add_executable(test_rawprodio test_rawprodio.c)
add_executable(test_i16stream test_i16stream.c)
add_executable(test_config_set config_set.c)
add_executable(test_convert test_convert.c)
add_executable(remove_sweep remove_sweep.c)

set_target_properties(test_config_set PROPERTIES COMPILE_FLAGS
                                                 "-DCONFIG_SET_UNITTEST")
set_target_properties(test_rawprodio PROPERTIES COMPILE_FLAGS "-DNO_NETCDF")

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

install(
  FILES ${INST_INCLUDES}
  DESTINATION ${IRIS_INCLUDE}
  COMPONENT devel)
