# Copyright (C) 2025-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

find_package(OpenVINOGenAI REQUIRED
    PATHS
        "${CMAKE_BINARY_DIR}"  # Reuse the package from the build.
        ${OpenVINO_DIR}  # GenAI may be installed alogside OpenVINO.
    NO_CMAKE_FIND_ROOT_PATH
)

include(${CMAKE_CURRENT_SOURCE_DIR}/../fetch_opencv.cmake)

function(add_sample_executable target_name)
    if("${target_name}" STREQUAL "image_video_embedding")
        add_executable(${target_name}
            ${target_name}.cpp
            ../visual_language_chat/load_image.cpp
            ../visual_language_chat/load_video.cpp)
        target_include_directories(${target_name} PRIVATE "${CMAKE_BINARY_DIR}")
    else()
        add_executable(${target_name} ${target_name}.cpp)
    endif()
    if("${target_name}" STREQUAL "image_video_embedding")
        ov_genai_link_opencv(${target_name} core imgproc videoio)
    endif()
    target_link_libraries(${target_name} PRIVATE openvino::genai)
    set_target_properties(${target_name} PROPERTIES
        COMPILE_PDB_NAME ${target_name}
        # Ensure out-of-box LC_RPATH on macOS with SIP
        INSTALL_RPATH_USE_LINK_PATH ON)
    install(TARGETS ${target_name}
            RUNTIME DESTINATION samples_bin/
            COMPONENT samples_bin
            EXCLUDE_FROM_ALL)
endfunction()

set(SAMPLE_LIST text_embeddings text_rerank image_video_embedding)

foreach(sample ${SAMPLE_LIST})
    add_sample_executable(${sample})
endforeach()


# benchmark_genai
include(FetchContent)

if(POLICY CMP0135)
    cmake_policy(SET CMP0135 NEW)
endif()
