# http://www.leptonica.org
#
# http://www.leptonica.org/source/leptonica-1.74.4.tar.gz

### DEPENDS ###
DKDEPEND(zlib)
DKDEPEND(tiff)
DKDEPEND(libpng)
IF(ANDROID)
	DKDEPEND(jpeg)
ELSE()
	DKDEPEND(libjpeg-turbo)
ENDIF()
DKDEPEND(giflib)


### VERSION ###
DKSET(LEPTONICA_MAJOR 1)
DKSET(LEPTONICA_MINOR 74)
DKSET(LEPTONICA_BUILD 4)
DKSET(LEPTONICA_VERSION ${LEPTONICA_MAJOR}.${LEPTONICA_MINOR}.${LEPTONICA_BUILD})
DKSET(LEPTONICA_NAME leptonica-${LEPTONICA_VERSION})
DKSET(LEPTONICA_DL http://www.leptonica.org/source/leptonica-${LEPTONICA_MAJOR}.${LEPTONICA_MINOR}.${LEPTONICA_BUILD}.tar.gz)
DKSET(LEPTONICA ${3RDPARTY}/${LEPTONICA_NAME})


### INSTALL ###
DKINSTALL(${LEPTONICA_DL} leptonica ${LEPTONICA})


### LINK ###
DKINCLUDE(${LEPTONICA})
DKINCLUDE(${LEPTONICA}/${OS}/src)
DKINCLUDE(${LEPTONICA}/${OS}/${RELEASE_DIR}/src)
WIN_DEBUG_LIB(${LEPTONICA}/${OS}/src/${DEBUG_DIR}/${LEPTONICA_NAME}d.lib)
WIN_RELEASE_LIB(${LEPTONICA}/${OS}/src/${RELEASE_DIR}/${LEPTONICA_NAME}.lib)
APPLE_DEBUG_LIB(${LEPTONICA}/${OS}/src/${DEBUG_DIR}/libleptonica.a)
APPLE_RELEASE_LIB(${LEPTONICA}/${OS}/src/${RELEASE_DIR}/libleptonica.a)
LINUX_DEBUG_LIB(${LEPTONICA}/${OS}/${DEBUG_DIR}/src/libleptonica.a)
LINUX_RELEASE_LIB(${LEPTONICA}/${OS}/${RELEASE_DIR}/src/libleptonica.a)
ANDROID_DEBUG_LIB(${LEPTONICA}/${OS}/${DEBUG_DIR}/obj/local/armeabi-v7a/libleptonica.a)
ANDROID_RELEASE_LIB(${LEPTONICA}/${OS}/${RELEASE_DIR}/obj/local/armeabi-v7a/libleptonica.a)


### 3rdParty Link ###
DKSET(LEPTONICA_WIN -DLeptonica_DIR=${LEPTONICA}/${OS})


### COMPILE ###
WIN_PATH(${LEPTONICA}/${OS})
WIN32_COMMAND(${DKCMAKE_WIN32} -DSTATIC=ON ${ZLIB_WIN} ${TIFF_WIN} ${PNG_WIN} ${JPEG_WIN} ${GIF_WIN} ${LEPTONICA})
WIN64_COMMAND(${DKCMAKE_WIN64} -DSTATIC=ON -DCMAKE_INSTALL_PREFIX=${LEPTONICA} ${ZLIB_WIN} ${TIFF_WIN} ${PNG_WIN} ${JPEG_WIN} ${GIF_WIN} ${LEPTONICA})
WIN_VS(${LEPTONICA_NAME} LEPTONICA.sln leptonica)


MAC_PATH(${LEPTONICA}/${OS})
MAC64_COMMAND(${DKCMAKE_MAC64} -DSTATIC=ON -DCMAKE_INSTALL_PREFIX=${LEPTONICA} ${ZLIB_APPLE} ${TIFF_APPLE} ${PNG_APPLE} ${JPEG_APPLE} ${GIF_APPLE} ${LEPTONICA})
MAC_XCODE(${LEPTONICA_NAME} leptonica)


IOS_PATH(${LEPTONICA}/${OS})
IOS64_COMMAND(${DKCMAKE_IOS64} -DSTATIC=ON -DCMAKE_INSTALL_PREFIX=${LEPTONICA} ${ZLIB_APPLE} ${TIFF_APPLE} ${PNG_APPLE} ${JPEG_APPLE} ${GIF_APPLE} ${LEPTONICA})
IOS_XCODE(${LEPTONICA_NAME} leptonica)


IOSSIM_PATH(${LEPTONICA}/${OS})
IOSSIM64_COMMAND(${DKCMAKE_IOSSIM64} -DSTATIC=ON -DCMAKE_INSTALL_PREFIX=${LEPTONICA} ${SDL2_APPLE} ${TIFF_APPLE} ${PNG_APPLE} ${JPEG_APPLE} ${GIF_APPLE} ${LEPTONICA})
IOSSIM_XCODE(${LEPTONICA_NAME} leptonica)


LINUX_DEBUG_PATH(${LEPTONICA}/${OS}/${DEBUG_DIR})
LINUX_DEBUG_COMMAND(${DKCMAKE_LINUX_DEBUG} -DSTATIC=ON -DCMAKE_INSTALL_PREFIX=${LEPTONICA} ${ZLIB_LINUX} ${TIFF_LINUX} ${PNG_APPLE} ${JPEG_LINUX} ${GIF_LINUX} ${LEPTONICA})
LINUX_DEBUG_COMMAND(make leptonica)

LINUX_RELEASE_PATH(${LEPTONICA}/${OS}/${RELEASE_DIR})
LINUX_RELEASE_COMMAND(${DKCMAKE_LINUX_RELEASE} -DSTATIC=ON -DCMAKE_INSTALL_PREFIX=${LEPTONICA} ${ZLIB_LINUX} ${TIFF_LINUX} ${PNG_APPLE} ${JPEG_LINUX} ${GIF_LINUX} ${LEPTONICA})
LINUX_RELEASE_COMMAND(make leptonica)


RASPBERRY_DEBUG_PATH(${LEPTONICA}/${OS}/${DEBUG_DIR})
RASPBERRY_DEBUG_COMMAND(${DKCMAKE_RASPBERRY_DEBUG} -DSTATIC=ON -DCMAKE_INSTALL_PREFIX=${LEPTONICA} ${ZLIB_RASPBERRY} ${TIFF_RASPBERRY} ${PNG_APPLE} ${JPEG_RASPBERRY} ${GIF_RASPBERRY} ${LEPTONICA})
RASPBERRY_DEBUG_COMMAND(make leptonica)

RASPBERRY_RELEASE_PATH(${LEPTONICA}/${OS}/${RELEASE_DIR})
RASPBERRY_RELEASE_COMMAND(${DKCMAKE_RASPBERRY_RELEASE} -DSTATIC=ON -DCMAKE_INSTALL_PREFIX=${LEPTONICA} ${ZLIB_RASPBERRY} ${TIFF_RASPBERRY} ${PNG_APPLE} ${JPEG_RASPBERRY} ${GIF_RASPBERRY} ${LEPTONICA})
RASPBERRY_RELEASE_COMMAND(make leptonica)


ANDROID_NDK(${LEPTONICA_NAME})
