# levmar CMake file

PROJECT(LEVMAR)

find_package(LAPACK REQUIRED)
find_package(BLAS REQUIRED)

# levmar static library source files
ADD_LIBRARY(levmar STATIC
  lm.c Axb.c misc.c lmlec.c lmbc.c lmblec.c lmbleic.c
  levmar.h misc.h compiler.h
)
target_compile_options(levmar PUBLIC -O3 -funroll-loops -Wall -fPIC)
target_link_libraries(levmar PUBLIC LAPACK::LAPACK BLAS::BLAS)

# levmar shared library source files
ADD_LIBRARY(levmarShared SHARED
  lm.c Axb.c misc.c lmlec.c lmbc.c lmblec.c lmbleic.c
  levmar.h misc.h compiler.h
)
target_compile_options(levmarShared PUBLIC -O3 -shared -funroll-loops -Wall -fPIC)
target_link_libraries(levmarShared PUBLIC LAPACK::LAPACK BLAS::BLAS)
set_target_properties(levmarShared PROPERTIES OUTPUT_NAME levmar)

# Installation
install(TARGETS levmar LIBRARY DESTINATION ${MANYO_LIB_PATH})
install(TARGETS levmarShared LIBRARY DESTINATION ${MANYO_LIB_PATH})
install(FILES compiler.h  levmar.h  lm.h  misc.h
        DESTINATION include/manyo/levmar)
