cmake_minimum_required(VERSION 3.0)

project(uvosunwrap)

set(SRC_FILES_LIB src/unwrap.cpp src/drawing.cpp src/matutils.cpp src/bgremoval.cpp src/charuco.cpp src/harris.cpp src/log.cpp)

set(SRC_FILES_APP src/main.cpp)

find_package( OpenCV REQUIRED )

add_library(${PROJECT_NAME} SHARED ${SRC_FILES_LIB})
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})
target_include_directories(${PROJECT_NAME} PRIVATE ${OpenCV_INCLUDE_DIRS})
target_compile_options(${PROJECT_NAME} PRIVATE "-std=c++17" "-Wall" "-O2" "-fno-strict-aliasing")

link_directories(${CMAKE_CURRENT_BINARY_DIR})

add_executable(${PROJECT_NAME}_cli ${SRC_FILES_APP})
target_link_libraries( ${PROJECT_NAME}_cli ${OpenCV_LIBS} -l${PROJECT_NAME})
target_include_directories(${PROJECT_NAME}_cli PRIVATE  ${OpenCV_INCLUDE_DIRS} )
add_dependencies(${PROJECT_NAME}_cli ${PROJECT_NAME})
target_compile_options(${PROJECT_NAME}_cli PRIVATE "-std=c++17" "-Wall" "-O2" "-fno-strict-aliasing")

set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s")


set(CMAKE_INSTALL_PREFIX "/usr")
install(TARGETS ${PROJECT_NAME}_cli RUNTIME DESTINATION bin)
install(TARGETS ${PROJECT_NAME} DESTINATION lib)
install(DIRECTORY src/uvosunwrap/ DESTINATION include/${PROJECT_NAME} FILES_MATCHING PATTERN "*.h")
