cmake_minimum_required(VERSION 3.16)
project(ARCDesktopProject LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

if(WIN32)
    # Укажи путь к Qt6
    set(CMAKE_PREFIX_PATH "C:/Qt/6.9.0/msvc2022_arm64")
    list(APPEND CMAKE_PREFIX_PATH "C:/Users/User/.vcpkg-clion/vcpkg/installed/arm64-windows")
    #vcpkg install tesseract:arm64-windows
    set(Tesseract_DIR "C:/Users/User/.vcpkg-clion/vcpkg/installed/arm64-windows/share/tesseract")

    find_package(Tesseract CONFIG REQUIRED)
elseif(APPLE)
    # Укажи путь к Qt6
    set(CMAKE_PREFIX_PATH "/opt/homebrew/opt/qt")
    include_directories("/opt/homebrew/opt/tesseract/include")
    link_directories("/opt/homebrew/opt/tesseract/lib")
endif()

find_package(Qt6 REQUIRED COMPONENTS Widgets)

file(GLOB_RECURSE VIEW_SOURCES
        "${CMAKE_CURRENT_SOURCE_DIR}/views/*.cpp"
        "${CMAKE_CURRENT_SOURCE_DIR}/views/*.h"
)

file(GLOB_RECURSE SERVICES_SOURCES
        "${CMAKE_CURRENT_SOURCE_DIR}/services/*.cpp"
        "${CMAKE_CURRENT_SOURCE_DIR}/services/*.h"
)

add_executable(ARCDesktopProject
        main.cpp
        ${VIEW_SOURCES}
        ${SERVICES_SOURCES}
)

if(WIN32)
    target_link_libraries(ARCDesktopProject
            Qt6::Widgets
            Tesseract::libtesseract
    )

    # Копирование изображений в директорию сборки
    file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/images" DESTINATION "${CMAKE_BINARY_DIR}")
    file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/rus.traineddata" DESTINATION "${CMAKE_BINARY_DIR}")

elseif(APPLE)
    target_link_libraries(ARCDesktopProject
            Qt6::Widgets
            tesseract
    )
endif()