# ANSLPR — License Plate Recognition DLL
# Explicit source list from original vcxproj
set(ANSLPR_SOURCES
    ANSLPR.cpp
    ANSLPR_CPU.cpp
    ANSLPR_OD.cpp
    ANSGpuFrameRegistry.cpp
    dllmain.cpp
    pch.cpp
)
file(GLOB ANSLPR_HEADERS "*.h")
file(GLOB ANSLPR_INCLUDE_HEADERS "include/*.h")

# PaddleOCR sources compiled into ANSLPR (from original vcxproj)
set(PADDLE_SOURCES
    ${CMAKE_SOURCE_DIR}/modules/ANSOCR/ANSPaddleOCR/src/clipper.cpp
    ${CMAKE_SOURCE_DIR}/modules/ANSOCR/ANSPaddleOCR/src/ocr_cls.cpp
    ${CMAKE_SOURCE_DIR}/modules/ANSOCR/ANSPaddleOCR/src/ocr_det.cpp
    ${CMAKE_SOURCE_DIR}/modules/ANSOCR/ANSPaddleOCR/src/ocr_rec.cpp
    ${CMAKE_SOURCE_DIR}/modules/ANSOCR/ANSPaddleOCR/src/paddleocr.cpp
    ${CMAKE_SOURCE_DIR}/modules/ANSOCR/ANSPaddleOCR/src/paddleocr_utility.cpp
    ${CMAKE_SOURCE_DIR}/modules/ANSOCR/ANSPaddleOCR/src/paddlestructure.cpp
    ${CMAKE_SOURCE_DIR}/modules/ANSOCR/ANSPaddleOCR/src/postprocess_op.cpp
    ${CMAKE_SOURCE_DIR}/modules/ANSOCR/ANSPaddleOCR/src/preprocess_op.cpp
    ${CMAKE_SOURCE_DIR}/modules/ANSOCR/ANSPaddleOCR/src/structure_layout.cpp
    ${CMAKE_SOURCE_DIR}/modules/ANSOCR/ANSPaddleOCR/src/structure_table.cpp
)

add_library(ANSLPR SHARED
    ${ANSLPR_HEADERS}
    ${ANSLPR_SOURCES}
    ${ANSLPR_INCLUDE_HEADERS}
    ${PADDLE_SOURCES}
)

target_include_directories(ANSLPR PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}
)

target_include_directories(ANSLPR PRIVATE
    ${CMAKE_CURRENT_SOURCE_DIR}/include
    ${CMAKE_SOURCE_DIR}/engines/ONNXEngine
    ${CMAKE_SOURCE_DIR}/engines/OpenVINOEngine/include
    ${CMAKE_SOURCE_DIR}/engines/TensorRTAPI/include
    ${CMAKE_SOURCE_DIR}/modules/ANSODEngine
    ${CMAKE_SOURCE_DIR}/modules/ANSOCR
    ${CMAKE_SOURCE_DIR}/modules/ANSOCR/ANSPaddleOCR
    ${CMAKE_SOURCE_DIR}/modules/ANSOCR/ANSPaddleOCR/include
    ${SHARED_INCLUDE_DIR}
)

target_link_libraries(ANSLPR
    PUBLIC  ANSLibsLoader
    PRIVATE ANSODEngine
    PRIVATE ANSLicensingSystem
    PRIVATE ANSMOT
    PRIVATE labview
    PRIVATE spdlog_dep
    PRIVATE opencv
    PRIVATE onnxruntime
    PRIVATE tensorrt
    PRIVATE openvino
    PRIVATE CUDA::cudart
)

target_compile_definitions(ANSLPR PRIVATE UNICODE _UNICODE
    ANSLPR_EXPORTS
    _USRDLL
    ANSLPR_USE_CUDA
    LPR_EDITOR_USE_CUDA
)

target_precompile_headers(ANSLPR PRIVATE pch.h)
