# https://github.com/tesseract-ocr/tessdoc
#
# https://github.com/tesseract-ocr/tessdoc/archive/refs/heads/master.zip

DKDEPEND(leptonica)

### VERSION ###
DKSET(TESSERACT_VERSION master)
DKSET(TESSERACT_NAME tesseract-${TESSERACT_VERSION})
DKSET(TESSERACT_DL https://github.com/tesseract-ocr/tessdoc/archive/refs/heads/${TESSERACT_VERSION}.zip)
DKSET(TESSERACT ${3RDPARTY}/${TESSERACT_NAME})


### INSTALL ###
DKINSTALL(${TESSERACT_DL} tesseract ${TESSERACT})


### LINK ###
DKINCLUDE(${TESSERACT})
DKINCLUDE(${TESSERACT}/ccutil)
DKINCLUDE(${TESSERACT}/ccstruct)
DKINCLUDE(${TESSERACT}/ccmain)
WIN_DEBUG_LIB(${TESSERACT}/${OS}/${DEBUG_DIR}/tesseract305d.lib)
WIN_RELEASE_LIB(${TESSERACT}/${OS}/${RELEASE_DIR}/tesseract305.lib)
APPLE_DEBUG_LIB(${TESSERACT}/${OS}/${DEBUG_DIR}/liblibtesseract.a)
APPLE_RELEASE_LIB(${TESSERACT}/${OS}/${RELEASE_DIR}/liblibtesseract.a)
LINUX_DEBUG_LIB(${TESSERACT}/${OS}/${DEBUG_DIR}/liblibtesseract.a)
LINUX_RELEASE_LIB(${TESSERACT}/${OS}/${RELEASE_DIR}/liblibtesseract.a)
ANDROID_DEBUG_LIB(${TESSERACT}/${OS}/${DEBUG_DIR}/obj/local/armeabi-v7a/libtesseract.a)
ANDROID_RELEASE_LIB(${TESSERACT}/${OS}/${RELEASE_DIR}/obj/local/armeabi-v7a/libtesseract.a)


### COMPILE ###
WIN_PATH(${TESSERACT}/${OS})
WIN32_COMMAND(${DKCMAKE_WIN32} -DSTATIC=ON -DBUILD_TRAINING_TOOLS=OFF ${LEPTONICA_WIN} ${TESSERACT})
WIN64_COMMAND(${DKCMAKE_WIN64} -DSTATIC=ON -DBUILD_TRAINING_TOOLS=OFF ${LEPTONICA_WIN} ${TESSERACT})
WIN_VS(${TESSERACT_NAME} tesseract.sln libtesseract)


MAC_PATH(${TESSERACT}/${OS})
MAC64_COMMAND(${DKCMAKE_MAC64} -DSTATIC=ON -DBUILD_TRAINING_TOOLS=OFF -DLeptonica_DIR=${LEPTONICA}/${OS} ${TESSERACT})
MAC_XCODE(${TESSERACT_NAME} libtesseract)

IOS_PATH(${TESSERACT}/${OS})
IOS64_COMMAND(${DKCMAKE_IOS64} -DSTATIC=ON -DBUILD_TRAINING_TOOLS=OFF -DLeptonica_DIR=${LEPTONICA}/${OS} ${TESSERACT})
IOS_XCODE(${TESSERACT_NAME} libtesseract)

IOSSIM_PATH(${TESSERACT}/${OS})
IOSSIM64_COMMAND(${DKCMAKE_IOSSIM64} -DSTATIC=ON -DBUILD_TRAINING_TOOLS=OFF -DLeptonica_DIR=${LEPTONICA}/${OS} ${TESSERACT})
IOSSIM_XCODE(${TESSERACT_NAME} libtesseract)

LINUX_DEBUG_PATH(${TESSERACT}/${OS}/Debug)
LINUX_DEBUG_COMMAND(${DKCMAKE_LINUX_DEBUG} -DSTATIC=ON "-DCMAKE_CXX_FLAGS=-DGRAPHICS_DISABLED" -DBUILD_TRAINING_TOOLS=OFF -DLeptonica_DIR=${LEPTONICA}/${OS}/${RELEASE_DIR} ${TESSERACT})
LINUX_DEBUG_COMMAND(make libtesseract)

LINUX_RELEASE_PATH(${TESSERACT}/${OS}/${RELEASE_DIR})
LINUX_RELEASE_COMMAND(${DKCMAKE_LINUX_RELEASE} -DSTATIC=ON "-DCMAKE_CXX_FLAGS=-DGRAPHICS_DISABLED" -DBUILD_TRAINING_TOOLS=OFF -DLeptonica_DIR=${LEPTONICA}/${OS}/${RELEASE_DIR} ${TESSERACT})
LINUX_RELEASE_COMMAND(make libtesseract)

ANDROID_NDK(${TESSERACT_NAME})