set(PACKAGE base-himath_lib)

message(STATUS ${PACKAGE})

list(APPEND INST_INCLUDES convolute.h himath_lib.h numutil.h)
list(APPEND APPS map_test xypoly_test polyfittest iir_test)
set(LIB_NAME himath)

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

set(SOURCE_FILES
    convolute.h
    himath_lib.h
    numutil.h
    convolute.c
    covsrt.c
    fft.c
    gaussj.c
    himath_lib_nls_init.c
    lfit.c
    linefit.c
    maproj.c
    MapProjInt.c
    matrix.c
    mrqmin.c
    poly.c
    triangle.c
    xypoly.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})

set_target_properties(${LIB_NAME} PROPERTIES COMPILE_FLAGS "-fPIC")

add_executable(map_test map_test.c)
target_link_libraries(map_test himath user m bsd)

add_executable(xypoly_test xypoly_test.c)
target_link_libraries(xypoly_test himath user m bsd)

add_executable(polyfittest polyfittest.c)
target_link_libraries(polyfittest himath user m bsd)

add_executable(iir_test iir_test.c)
target_link_libraries(iir_test himath user m bsd)

add_subdirectory(po)

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

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