# Pipeline samples - independent build
cmake_minimum_required(VERSION 3.15)
project(pipeline_samples CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if(WIN32)
    # Source files are UTF-8; avoid C4819 on systems whose active code page
    # (e.g. 936/GBK) cannot represent non-ASCII bytes.
    add_compile_options(/utf-8)
endif()

# Check SDK environment
if(NOT DEFINED ENV{DLICC_PATH})
    message(FATAL_ERROR "Please source sdk/env.sh first")
endif()
get_filename_component(SDK_PATH "$ENV{DLICC_PATH}/.." ABSOLUTE)

# Include paths
include_directories(${SDK_PATH}/include)
include_directories(${SDK_PATH}/include/dldt)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../common)
link_directories(${SDK_PATH}/lib)

# Custom FFmpeg location (Windows custom build). Pass -DFFMPEG_ROOT=...,
# the same variable the top-level CMakeLists uses. No-op on Linux/apt
# (headers in /usr/include are found automatically).
if(DEFINED FFMPEG_ROOT AND NOT FFMPEG_ROOT STREQUAL "")
    include_directories(${FFMPEG_ROOT}/include)
    link_directories(${FFMPEG_ROOT}/lib)
endif()

find_package(Threads REQUIRED)

set(FFMPEG_LIBS avformat avcodec swscale swresample avutil)

if(WIN32)
    set(PLATFORM_LIBS "")
else()
    set(PLATFORM_LIBS dl)
endif()

set(SDK_CORE_LIBS curt dljpeg dlvid dlnne)

# YOLOv5 pipeline sample
add_executable(yolov5_pipeline yolov5_pipeline.cc)
target_link_libraries(yolov5_pipeline PRIVATE dldt_jpeg dldt_video dldt_network dldt_cuda_kernel
    ${SDK_CORE_LIBS} ${FFMPEG_LIBS} Threads::Threads ${PLATFORM_LIBS})

# YOLOv8 pipeline sample
add_executable(yolov8_pipeline yolov8_pipeline.cc)
target_link_libraries(yolov8_pipeline PRIVATE dldt_jpeg dldt_video dldt_network dldt_cuda_kernel
    ${SDK_CORE_LIBS} ${FFMPEG_LIBS} Threads::Threads ${PLATFORM_LIBS})
