# https://github.com/webmproject/libwebp
#
# https://github.com/webmproject/libwebp/archive/refs/tags/v1.0.3.zip

### DEPENDS ###
DKDEPEND(zlib)
DKDEPEND(libpng)
DKDEPEND(tiff)
DKDEPEND(libjpeg-turbo)
DKDEPEND(giflib)
DKDEPEND(sdl2)

### VERSION ###
DKSET(WEBP_MAJOR 1)
DKSET(WEBP_MINOR 0)
DKSET(WEBP_BUILD 3)
DKSET(WEBP_VERSION ${WEBP_MAJOR}.${WEBP_MINOR}.${WEBP_BUILD})
DKSET(WEBP_NAME libwebp-${WEBP_VERSION})
DKSET(WEBP_DL https://github.com/webmproject/libwebp/archive/refs/tags/v${WEBP_VERSION}.zip)
DKSET(WEBP ${3RDPARTY}/${WEBP_NAME})


### INSTALL ###
DKINSTALL(${WEBP_DL} libwebp ${WEBP})


### DKPLUGINS LINK ###
DKINCLUDE(${WEBP})
WIN_DEBUG_LIB(${WEBP}/${OS}/${DEBUG_DIR}/libwebp.lib)
WIN_RELEASE_LIB(${WEBP}/${OS}/${RELEASE_DIR}/libwebp.lib)
APPLE_DEBUG_LIB(${WEBP}/${OS}/WebP.build/${DEBUG_DIR}/webpdecode.build/libwebpdecode.a)
APPLE_RELEASE_LIB(${WEBP}/${OS}/WebP.build/${RELEASE_DIR}/webpdecode.build/libwebpdecode.a)
APPLE_DEBUG_LIB(${WEBP}/${OS}/WebP.build/${DEBUG_DIR}/webpdsp.build/libwebpdsp.a)
APPLE_RELEASE_LIB(${WEBP}/${OS}/WebP.build/${RELEASE_DIR}/webpdsp.build/libwebpdsp.a)
APPLE_DEBUG_LIB(${WEBP}/${OS}/WebP.build/${DEBUG_DIR}/webpencode.build/libwebpencode.a)
APPLE_RELEASE_LIB(${WEBP}/${OS}/WebP.build/${RELEASE_DIR}/webpencode.build/libwebpencode.a)
APPLE_DEBUG_LIB(${WEBP}/${OS}/WebP.build/${DEBUG_DIR}/webputils.build/libwebputils.a)
APPLE_RELEASE_LIB(${WEBP}/${OS}/WebP.build/${RELEASE_DIR}/webputils.build/libwebputils.a)
LINUX_DEBUG_LIB(${WEBP}/${OS}/${DEBUG_DIR}/libwebp.a)
LINUX_RELEASE_LIB(${WEBP}/${OS}/${RELEASE_DIR}/libwebp.a)
RASPBERRY_DEBUG_LIB(${WEBP}/${OS}/${DEBUG_DIR}/libwebp.a)
RASPBERRY_RELEASE_LIB(${WEBP}/${OS}/${RELEASE_DIR}/libwebp.a)
ANDROID_DEBUG_LIB(${WEBP}/${OS}/${DEBUG_DIR}/libwebp.a)
ANDROID_RELEASE_LIB(${WEBP}/${OS}/${RELEASE_DIR}/libwebp.a)


#TODO
### 3RDPARTY LINK ###
#DKSET(WEBP_WIN -DWEBP_INCLUDE_DIR=${WEBP} -DWEBP_LIBRARY_DEBUG=${WEBP}/${OS}/${DEBUG_DIR}/libwebpd.lib -DWEBP_LIBRARY_RELEASE=${WEBP}/${OS}/${RELEASE_DIR}/libwebp.lib)
#DKSET(WEBP_APPLE -DWEBP_INCLUDE_DIR=${WEBP} -DWEBP_LIBRARY_DEBUG=${WEBP}/${OS}/${DEBUG_DIR}/libwebpd.a -DWEBP_LIBRARY_RELEASE=${WEBP}/${OS}/${RELEASE_DIR}/libwebp.a)
#DKSET(WEBP_LINUX -DWEBP_INCLUDE_DIR=${WEBP} -DWEBP_LIBRARY_DEBUG=${WEBP}/${OS}/${DEBUG_DIR}/libwebpd.a -DWEBP_LIBRARY_RELEASE=${WEBP}/${OS}/${RELEASE_DIR}/libwebp.a)
#DKSET(WEBP_RASPBERRY -DWEBP_INCLUDE_DIR=${WEBP} -DWEBP_LIBRARY_DEBUG=${WEBP}/${OS}/${DEBUG_DIR}/libwebpd.a -DWEBP_LIBRARY_RELEASE=${WEBP}/${OS}/${RELEASE_DIR}/libwebp.a)
#DKSET(WEBP_ANDROID -DWEBP_INCLUDE_DIR=${WEBP} -DWEBP_LIBRARY_DEBUG=${WEBP}/${OS}/${DEBUG_DIR}/libwebp.a -DWEBP_LIBRARY_RELEASE=${WEBP}/${OS}/${RELEASE_DIR}/libwebp.a)
	

### COMPILE ###
WIN_PATH(${WEBP}/${OS})
WIN32_COMMAND(${DKCMAKE_WIN32} ${ZLIB_WIN} ${PNG_WIN} ${JPEG_WIN} ${TIFF_WIN} ${GIF_WIN} ${SDL2_WIN} ${WEBP})
WIN64_COMMAND(${DKCMAKE_WIN64} ${PNG_WIN64} ${JPEG_WIN64} ${TIFF_WIN64} ${GIF_WIN64} ${SDL2_WIN64} ${WEBP})
WIN_VS(${WEBP_NAME} WebP.sln webp)


MAC_PATH(${WEBP}/${OS})
MAC32_COMMAND(${DKCMAKE_MAC32} ${PNG_MAC32} ${JPEG_MAC32} ${TIFF_MAC32} ${GIF_MAC32} ${SDL2_MAC32} ${WEBP})
MAC64_COMMAND(${DKCMAKE_MAC64} ${PNG_MAC64} ${JPEG_MAC64} ${TIFF_MAC64} ${GIF_MAC64} ${SDL2_MAC64} ${WEBP})
MAC_XCODE(${WEBP_NAME} webp)


IOS_PATH(${WEBP}/${OS})
IOS32_COMMAND(${DKCMAKE_IOS32} ${WEBP})
IOS64_COMMAND(${DKCMAKE_IOS64} ${WEBP})
IOS_XCODE(${WEBP_NAME} webp)


IOSSIM_PATH(${WEBP}/${OS})
IOSSIM32_COMMAND(${DKCMAKE_IOSSIM32} ${WEBP})
IOSSIM64_COMMAND(${DKCMAKE_IOSSIM64} ${WEBP})
IOSSIM_XCODE(${WEBP_NAME} webp)


LINUX_DEBUG_PATH(${WEBP}/${OS}/${DEBUG_DIR})
LINUX_DEBUG_COMMAND(${DKCMAKE_LINUX_DEBUG} ${WEBP})
LINUX_DEBUG_COMMAND(make all)

LINUX_RELEASE_PATH(${WEBP}/${OS}/${RELEASE_DIR})
LINUX_RELEASE_COMMAND(${DKCMAKE_LINUX_RELEASE} ${WEBP})
LINUX_RELEASE_COMMAND(make all)


RASPBERRY_DEBUG_PATH(${WEBP}/${OS}/${DEBUG_DIR})
RASPBERRY_DEBUG_COMMAND(${DKCMAKE_RASPBERRY_DEBUG} ${WEBP})
RASPBERRY_DEBUG_COMMAND(make all)

RASPBERRY_RELEASE_PATH(${WEBP}/${OS}/${RELEASE_DIR})
RASPBERRY_RELEASE_COMMAND(${DKCMAKE_RASPBERRY_RELEASE} ${WEBP})
RASPBERRY_RELEASE_COMMAND(make all)


##ANDROID_NDK(${WEBP_NAME})
ANDROID_PATH(${WEBP}/${OS})
ANDROID32_COMMAND(${DKCMAKE_ANDROID32} ${PNG_ANDROID32} ${JPEG_ANDROID32} ${TIFF_ANDROID32} ${GIF_ANDROID32} ${SDL2_ANDROID32} ${WEBP})
ANDROID64_COMMAND(${DKCMAKE_ANDROID64} ${PNG_ANDROID64} ${JPEG_ANDROID64} ${TIFF_ANDROID64} ${GIF_ANDROID64} ${SDL2_ANDROID64} ${WEBP})
ANDROID_VS(${WEBP_NAME} libwebp.sln webp)