cmake_minimum_required(VERSION 3.16)

project(kyimageproc)
aux_source_directory(. SOURCESCODE)
include_directories(.)

set(CMAKE_CXX_STANDARD 11)

add_library(kyimageproc SHARED ${SOURCESCODE})
set_target_properties(kyimageproc PROPERTIES VERSION 3.0.0 SOVERSION 3)

find_package(PkgConfig REQUIRED)
pkg_check_modules(KYSDKLOG kysdk-log)
find_package( OpenCV REQUIRED )
target_include_directories(kyimageproc PRIVATE ${KYSDKLOG_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS})
target_link_directories(kyimageproc PRIVATE ${KYSDKLOG_LIBRARY_DIRS} ${OpenCV_LIBRARY_DIRS})
target_link_libraries(kyimageproc PRIVATE ${KYSDKLOG_LIBRARIES} dl ${OpenCV_LIBRARIES})
target_link_options(kyimageproc PRIVATE "-Wl,-z,now")

add_executable(kyimage-test test/kyimage-test.c)
target_link_libraries(kyimage-test kyimageproc)

set(PREFIX "")
set(LIBS_INSTALL_DIR "${PREFIX}/usr/lib/kysdk/kysdk-system")
set(HEADERS_INSTALL_DIR "${PREFIX}/usr/include/kysdk/kysdk-system/")

# install(TARGETS kyimageproc LIBRARY DESTINATION ${LIBS_INSTALL_DIR})

# 包含 GNU 安装目录设置  
include(GNUInstallDirs)

# 安装库文件  
install(TARGETS kyimageproc
        DESTINATION ${CMAKE_INSTALL_LIBDIR})

install(FILES libkyimageproc.h DESTINATION ${HEADERS_INSTALL_DIR})
