# https://github.com/libsdl-org/SDL_image
#
# https://www.libsdl.org/projects/SDL_image/release/SDL2_image-2.0.1.zip
# https://www.libsdl.org/projects/SDL_image/release/SDL2_image-2.0.5.zip
# https://github.com/libsdl-org/SDL_image/archive/refs/heads/main.zip
#
# Notes:  VS compiler options
#
# DEBUG flags
# Debug Information Format:         C7 compatible (/Z7)
# Enable Enhanced Instruction Set:  Streaming SIMD Extensions (/arch:SSE)
# Inline function expansion:        Default
# Preprocessor Definitions:         _DEBUG WIN32 _WINDOWS LOAD_BMP LOAD_GIF LOAD_JPG LOAD_LBM LOAD_PCX LOAD_PNG LOAD_PNM LOAD_SVG LOAD_TGA LOAD_TIF LOAD_WEBP LOAD_XPM LOAD_XV 
#
# RELEASE flags)
# Debug information format:         Program Database (/Zi)
# Diagnostics Format:               OFF
# Enable C++ Exceptions             Yes (/EHsc)
# Inline function expansion         Any Suitable (/Ob2)
# Ommit frame pointers              OFF



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



### VERSION ###
DKSET(SDL2IMAGE_MAJOR 2)
DKSET(SDL2IMAGE_MINOR 0)
DKSET(SDL2IMAGE_BUILD 5)  
#if(ANDROID)
#	DKSET(SDL2IMAGE_VERSION ${SDL2IMAGE_MAJOR}.${SDL2IMAGE_MINOR}.${SDL2IMAGE_BUILD})
#else
	DKSET(SDL2IMAGE_VERSION main)
#endif
DKSET(SDL2IMAGE_VERSION main)
DKSET(SDL2IMAGE_NAME SDL2_image-${SDL2IMAGE_VERSION})
#DKSET(SDL2IMAGE_DL https://www.libsdl.org/projects/SDL_image/release/${SDL2IMAGE_NAME}.zip)
DKSET(SDL2IMAGE_DL https://github.com/libsdl-org/SDL_image/archive/refs/heads/${SDL2IMAGE_VERSION}.zip)  #main
DKSET(SDL2IMAGE ${3RDPARTY}/${SDL2IMAGE_NAME})


### INSTALL ###
DKINSTALL(${SDL2IMAGE_DL} sdl2_image ${SDL2IMAGE})


### DKPLUGINS LINK ###
DKINCLUDE(${SDL2IMAGE})
WIN_DEBUG_LIB(${SDL2IMAGE}/${OS}/lib/${DEBUG_DIR}/SDL_image.lib)
WIN_RELEASE_LIB(${SDL2IMAGE}/${OS}/lib/${RELEASE_DIR}/SDL_image.lib)
APPLE_DEBUG_LIB(${SDL2IMAGE}/${OS}/lib/${DEBUG_DIR}/SDL_image.a)
APPLE_RELEASE_LIB(${SDL2IMAGE}/${OS}/lib/${RELEASE_DIR}/SDL_image.a)
LINUX_DEBUG_LIB(${SDL2IMAGE}/${OS}/${DEBUG_DIR}/lib/SDL_image.a)
LINUX_RELEASE_LIB(${SDL2IMAGE}/${OS}/${RELEASE_DIR}/lib/SDL_image.a)
RASPBERRY_DEBUG_LIB(${SDL2IMAGE}/${OS}/${DEBUG_DIR}/lib/SDL_image.a)
RASPBERRY_RELEASE_LIB(${SDL2IMAGE}/${OS}/${RELEASE_DIR}/lib/SDL_image.a)
##ANDROID_DEBUG_LIB(${SDL2IMAGE}/${OS}/${DEBUG_DIR}/obj/local/armeabi-v7a/libSDL2_image.a)
##ANDROID_RELEASE_LIB(${SDL2IMAGE}/${OS}/${RELEASE_DIR}/obj/local/armeabi-v7a/libSDL2_image.a)
ANDROID_DEBUG_LIB(${SDL2IMAGE}/${OS}/lib/${DEBUG_DIR}/SDL_image.a)
ANDROID_RELEASE_LIB(${SDL2IMAGE}/${OS}/lib/${RELEASE_DIR}/SDL_image.a)


### 3RDPARTY LINK ###
DKSET(SDL2IMAGE_WIN 
-DSDL2_IMAGE_INCLUDE_DIR=${SDL2IMAGE}
-DSDL2_IMAGE_LIBRARY_TEMP=${SDL2IMAGE}/${OS}/lib/${RELEASE_DIR}/SDL_image.lib
-DSDL2_IMAGE_LIBRARY_DEBUG=${SDL2IMAGE}/${OS}/lib/${DEBUG_DIR}/SDL_image.lib 
-DSDL2_IMAGE_LIBRARY_RELEASE=${SDL2IMAGE}/${OS}/lib/${RELEASE_DIR}/SDL_image.lib)
	
DKSET(SDL2IMAGE_APPLE 
-DSDL2_IMAGE_INCLUDE_DIR=${SDL2IMAGE}
-DSDL2_IMAGE_LIBRARY_TEMP=${SDL2IMAGE}/${OS}/lib/${DEBUG_DIR}/SDL_image.a
-DSDL2_IMAGE_LIBRARY_DEBUG=${SDL2IMAGE}/${OS}/lib/${DEBUG_DIR}/SDL_image.a 
-DSDL2_IMAGE_LIBRARY_RELEASE=${SDL2IMAGE}/${OS}/lib/${RELEASE_DIR}/SDL_image.a)

DKSET(SDL2IMAGE_LINUX -DSDL2_IMAGE_INCLUDE_DIR=${SDL2IMAGE} -DSDL2_IMAGE_LIBRARY_DEBUG=${SDL2IMAGE}/${OS}/lib/${DEBUG_DIR}/SDL_image.a -DSDL2_IMAGE_LIBRARY_RELEASE=${SDL2IMAGE}/${OS}/lib/${RELEASE_DIR}/SDL_image.a)
DKSET(SDL2IMAGE_RASPBERRY -DSDL2_IMAGE_INCLUDE_DIR=${SDL2IMAGE} -DSDL2_IMAGE_LIBRARY_DEBUG=${SDL2IMAGE}/${OS}/lib/${DEBUG_DIR}/SDL_image.a -DSDL2_IMAGE_LIBRARY_RELEASE=${SDL2IMAGE}/${OS}/lib/${RELEASE_DIR}/SDL_image.a)
DKSET(SDL2IMAGE_ANDROID -DSDL2_IMAGE_INCLUDE_DIR=${SDL2IMAGE} -DSDL2_IMAGE_LIBRARY_DEBUG=${SDL2IMAGE}/${OS}/lib/${DEBUG_DIR}/SDL_image.a -DSDL2_IMAGE_LIBRARY_RELEASE=${SDL2IMAGE}/${OS}/lib/${RELEASE_DIR}/SDL_image.a)


### COMPILE ###
WIN_PATH(${SDL2IMAGE}/${OS})
WIN32_COMMAND(${DKCMAKE_WIN32} -DSDLIMAGE_SUPPORT_GIF=ON -DSDLIMAGE_SUPPORT_JPEG=ON -DSDLIMAGE_SUPPORT_PNG=ON -DSDLIMAGE_SUPPORT_WEBP=OFF ${SDL2_WIN} ${ZLIB_WIN} ${TIFF_WIN} ${PNG_WIN} ${JPEG_WIN} ${GIF_WIN} ${SDL2IMAGE})
WIN64_COMMAND(${DKCMAKE_WIN64} -DSDLIMAGE_SUPPORT_GIF=ON -DSDLIMAGE_SUPPORT_JPEG=ON -DSDLIMAGE_SUPPORT_PNG=ON -DSDLIMAGE_SUPPORT_WEBP=OFF ${SDL2_WIN} ${ZLIB_WIN} ${TIFF_WIN} ${PNG_WIN} ${JPEG_WIN} ${GIF_WIN} ${SDL2IMAGE})
WIN_VS(SDL2_image-${SDL2IMAGE_VERSION} SDLIMAGE.sln SDLIMAGE)


MAC_PATH(${SDL2IMAGE}/${OS})
MAC32_COMMAND(${DKCMAKE_MAC32} -DSDLIMAGE_SUPPORT_GIF=ON -DSDLIMAGE_SUPPORT_JPEG=ON -DSDLIMAGE_SUPPORT_PNG=ON -DSDLIMAGE_SUPPORT_WEBP=OFF ${SDL2_APPLE} ${ZLIB_APPLE} ${TIFF_APPLE} ${PNG_APPLE} ${JPEG_APPLE} ${GIF_APPLE} ${SDL2IMAGE})
MAC64_COMMAND(${DKCMAKE_MAC64} -DSDLIMAGE_SUPPORT_GIF=ON -DSDLIMAGE_SUPPORT_JPEG=ON -DSDLIMAGE_SUPPORT_PNG=ON -DSDLIMAGE_SUPPORT_WEBP=OFF ${SDL2_APPLE} ${ZLIB_APPLE} ${TIFF_APPLE} ${PNG_APPLE} ${JPEG_APPLE} ${GIF_APPLE} ${SDL2IMAGE})
MAC_XCODE(SDL2_image-${SDL2IMAGE_VERSION} SDLIMAGE)


IOS_PATH(${SDL2IMAGE}/${OS})
IOS64_COMMAND(${DKCMAKE_IOS64} -DSDLIMAGE_SUPPORT_GIF=ON -DSDLIMAGE_SUPPORT_JPEG=ON -DSDLIMAGE_SUPPORT_PNG=ON -DSDLIMAGE_SUPPORT_WEBP=OFF ${SDL2_APPLE} ${ZLIB_APPLE} ${TIFF_APPLE} ${PNG_APPLE} ${JPEG_APPLE} ${GIF_APPLE} ${SDL2IMAGE})
IOS_XCODE(SDL2_image-${SDL2IMAGE_VERSION} SDLIMAGE)


IOSSIM_PATH(${SDL2IMAGE}/${OS})
IOSSIM64_COMMAND(${DKCMAKE_IOSSIM64} -DSDLIMAGE_SUPPORT_GIF=ON -DSDLIMAGE_SUPPORT_JPEG=ON -DSDLIMAGE_SUPPORT_PNG=ON -DSDLIMAGE_SUPPORT_WEBP=OFF ${SDL2_APPLE} ${ZLIB_APPLE} ${TIFF_APPLE} ${PNG_APPLE} ${JPEG_APPLE} ${GIF_APPLE} ${SDL2IMAGE})
IOSSIM_XCODE(SDL2_image-${SDL2IMAGE_VERSION} SDLIMAGE)


LINUX32_DEBUG_PATH(${SDL2IMAGE}/${OS}/${DEBUG_DIR})
LINUX32_DEBUG_COMMAND(${DKCMAKE_LINUX32_DEBUG} -DSDLIMAGE_SUPPORT_GIF=ON -DSDLIMAGE_SUPPORT_JPEG=ON -DSDLIMAGE_SUPPORT_PNG=ON -DSDLIMAGE_SUPPORT_WEBP=OFF ${SDL2_LINUX} ${ZLIB_LINUX} ${TIFF_LINUX} ${PNG_LINUX} ${JPEG_LINUX} ${GIF_LINUX} ${SDL2IMAGE})
LINUX32_DEBUG_COMMAND(make SDLIMAGE)

LINUX32_RELEASE_PATH(${SDL2IMAGE}/${OS}/${RELEASE_DIR})
LINUX32_RELEASE_COMMAND(${DKCMAKE_LINUX32_RELEASE} -DSDLIMAGE_SUPPORT_GIF=ON -DSDLIMAGE_SUPPORT_JPEG=ON -DSDLIMAGE_SUPPORT_PNG=ON -DSDLIMAGE_SUPPORT_WEBP=OFF ${SDL2_LINUX} ${ZLIB_LINUX} ${TIFF_LINUX} ${PNG_LINUX} ${JPEG_LINUX} ${GIF_LINUX} ${SDL2IMAGE})
LINUX32_RELEASE_COMMAND(make SDLIMAGE)


LINUX64_DEBUG_PATH(${SDL2IMAGE}/${OS}/${DEBUG_DIR})
LINUX64_DEBUG_COMMAND(${DKCMAKE_LINUX64_DEBUG} -DSDLIMAGE_SUPPORT_GIF=ON -DSDLIMAGE_SUPPORT_JPEG=ON -DSDLIMAGE_SUPPORT_PNG=ON -DSDLIMAGE_SUPPORT_WEBP=OFF ${SDL2_LINUX} ${ZLIB_LINUX} ${TIFF_LINUX} ${PNG_LINUX} ${JPEG_LINUX} ${GIF_LINUX} ${SDL2IMAGE})
LINUX64_DEBUG_COMMAND(make)

LINUX64_RELEASE_PATH(${SDL2IMAGE}/${OS}/${RELEASE_DIR})
LINUX64_RELEASE_COMMAND(${DKCMAKE_LINUX64_RELEASE} -DSDLIMAGE_SUPPORT_GIF=ON -DSDLIMAGE_SUPPORT_JPEG=ON -DSDLIMAGE_SUPPORT_PNG=ON -DSDLIMAGE_SUPPORT_WEBP=OFF ${SDL2_LINUX} ${ZLIB_LINUX} ${TIFF_LINUX} ${PNG_LINUX} ${JPEG_LINUX} ${GIF_LINUX} ${SDL2IMAGE})
LINUX64_RELEASE_COMMAND(make)


RASPBERRY32_DEBUG_PATH(${SDL2IMAGE}/${OS}/${DEBUG_DIR})
RASPBERRY32_DEBUG_COMMAND(${DKCMAKE_RASPBERRY32_DEBUG} -DSDLIMAGE_SUPPORT_GIF=ON -DSDLIMAGE_SUPPORT_JPEG=ON -DSDLIMAGE_SUPPORT_PNG=ON -DSDLIMAGE_SUPPORT_WEBP=OFF ${SDL2_RASPBERRY} ${ZLIB_RASPBERRY} ${TIFF_RASPBERRY} ${PNG_RASPBERRY} ${JPEG_RASPBERRY} ${GIF_RASPBERRY} ${SDL2IMAGE})
RASPBERRY32_DEBUG_COMMAND(make SDLIMAGE)

RASPBERRY32_RELEASE_PATH(${SDL2IMAGE}/${OS}/${RELEASE_DIR})
RASPBERRY32_RELEASE_COMMAND(${DKCMAKE_RASPBERRY32_RELEASE} -DSDLIMAGE_SUPPORT_GIF=ON -DSDLIMAGE_SUPPORT_JPEG=ON -DSDLIMAGE_SUPPORT_PNG=ON -DSDLIMAGE_SUPPORT_WEBP=OFF ${SDL2_RASPBERRY} ${ZLIB_RASPBERRY} ${TIFF_RASPBERRY} ${PNG_RASPBERRY} ${JPEG_RASPBERRY} ${GIF_RASPBERRY} ${SDL2IMAGE})
RASPBERRY32_RELEASE_COMMAND(make SDLIMAGE)	
	
	
##ANDROID_NDK(SDL2_image-${SDL2IMAGE_VERSION})
ANDROID_PATH(${SDL2IMAGE}/${OS})
ANDROID32_COMMAND(${DKCMAKE_ANDROID32} -DSDLIMAGE_SUPPORT_GIF=ON -DSDLIMAGE_SUPPORT_JPEG=ON -DSDLIMAGE_SUPPORT_PNG=ON -DSDLIMAGE_SUPPORT_WEBP=OFF ${SDL2_ANDROID} ${ZLIB_ANDROID} ${TIFF_ANDROID} ${PNG_ANDROID} ${JPEG_ANDROID} ${GIF_ANDROID} ${SDL2IMAGE})
ANDROID64_COMMAND(${DKCMAKE_ANDROID64} -DSDLIMAGE_SUPPORT_GIF=ON -DSDLIMAGE_SUPPORT_JPEG=ON -DSDLIMAGE_SUPPORT_PNG=ON -DSDLIMAGE_SUPPORT_WEBP=OFF ${SDL2_ANDROID} ${ZLIB_ANDROID} ${TIFF_ANDROID} ${PNG_ANDROID} ${JPEG_ANDROID} ${GIF_ANDROID} ${SDL2IMAGE})
ANDROID_VS(SDL2_image-${SDL2IMAGE_VERSION} SDLIMAGE.sln SDLIMAGE)
