set(PACKAGE base-antenna_lib)

message(STATUS ${PACKAGE})

list(APPEND INST_INCLUDES antenna_lib.h antenna_int.h)
set(LIB_NAME antenna-iris)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}
                    ${CMAKE_CURRENT_SOURCE_DIR}/../config_lib
                    ${CMAKE_CURRENT_SOURCE_DIR}/../exthdr_lib
                    ${CMAKE_CURRENT_SOURCE_DIR}/../user_lib)

set(SOURCE_FILES
    ant_control.c
    ant_alert.c
    antenna_lib_nls_init.c
    ant_history.c
    AntInsert.c
    ant_iosubs.c
    ant_misc.c
    ant_model.c
    ant_motion.c
    ant_netrcv.c
    AntSet.c
    antsim_control.c
    antsim_misc.c
    antsim_motion.c
    ant_xh.c
    bite_driver.c
    bitsim_driver.c
    iant_pwrp.c
    iantsim_pwrp.c
    sun_position.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})

link_libraries(
  config-iris
  user-iris
  exthdr-iris
  dl
  m
  bsd)

add_executable(ant_rcvd ant_rcvd.c  ${SOURCE_FILES})
add_executable(ant_xmtd ant_xmtd.c  ${SOURCE_FILES})
add_executable(antsim_rcvd antsim_rcvd.c  ${SOURCE_FILES})
add_executable(antsim_xmtd antsim_xmtd.c  ${SOURCE_FILES})
add_executable(ant_logd ant_logd.c  ${SOURCE_FILES})

add_subdirectory(po)

install(
  TARGETS ant_rcvd
  DESTINATION ${IRIS_LIBEXEC_SERVICES}
  COMPONENT base)

install(
  TARGETS ant_xmtd
  DESTINATION ${IRIS_LIBEXEC_SERVICES}
  COMPONENT base)

install(
  TARGETS antsim_rcvd
  DESTINATION ${IRIS_LIBEXEC_SERVICES}
  COMPONENT base)

install(
  TARGETS antsim_xmtd
  DESTINATION ${IRIS_LIBEXEC_SERVICES}
  COMPONENT base)

install(
  TARGETS ant_logd
  DESTINATION ${IRIS_LIBEXEC_SERVICES}
  COMPONENT base)

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