# http://www.libpng.org/pub/png/libpng.html
#
# https://sourceforge.net/projects/libpng/files/libpng17/1.7.0-oldbetas/libpng-1.7.0beta34.tar.gz

DKDEPEND(zlib)

### VERSION ###
DKSET(PNG_MAJOR 1)
DKSET(PNG_MINOR 7)
DKSET(PNG_BUILD 0beta34)
DKSET(PNG_VERSION ${PNG_MAJOR}.${PNG_MINOR}.${PNG_BUILD})
DKSET(PNG_NAME libpng-${PNG_VERSION})
DKSET(PNG_DL https://sourceforge.net/projects/libpng/files/libpng${PNG_MAJOR}${PNG_MINOR}/${PNG_MAJOR}.${PNG_MINOR}.0-oldbetas/${PNG_NAME}.tar.gz)
DKSET(PNG ${3RDPARTY}/${PNG_NAME})


### INSTALL ###
DKINSTALL(${PNG_DL} libpng ${PNG})


### DKPLUGINS LINK ###
DKINCLUDE(${PNG})
DKINCLUDE(${PNG}/${OS})
DKINCLUDE(${PNG}/${OS}/${RELEASE_DIR})
ANDROID_INCLUDE(${PNG}/${OS}/$(BUILD_TYPE)/jni)
WIN_DEBUG_LIB(${PNG}/${OS}/${DEBUG_DIR}/libpng${PNG_MAJOR}${PNG_MINOR}_staticd.lib)
WIN_RELEASE_LIB(${PNG}/${OS}/${RELEASE_DIR}/libpng${PNG_MAJOR}${PNG_MINOR}_static.lib)
APPLE_DEBUG_LIB(${PNG}/${OS}/${DEBUG_DIR}/libpng${PNG_MAJOR}${PNG_MINOR}d.a)
APPLE_RELEASE_LIB(${PNG}/${OS}/${RELEASE_DIR}/libpng${PNG_MAJOR}${PNG_MINOR}.a)
LINUX_DEBUG_LIB(${PNG}/${OS}/${DEBUG_DIR}/libpng${PNG_MAJOR}${PNG_MINOR}d.a)
LINUX_RELEASE_LIB(${PNG}/${OS}/${RELEASE_DIR}/libpng${PNG_MAJOR}${PNG_MINOR}.a)
RASPBERRY_DEBUG_LIB(${PNG}/${OS}/${DEBUG_DIR}/libpng${PNG_MAJOR}${PNG_MINOR}d.a)
RASPBERRY_RELEASE_LIB(${PNG}/${OS}/${RELEASE_DIR}/libpng${PNG_MAJOR}${PNG_MINOR}.a)
ANDROID_DEBUG_LIB(${PNG}/${OS}/${DEBUG_DIR}/obj/local/armeabi-v7a/libpng.a)
ANDROID_RELEASE_LIB(${PNG}/${OS}/${RELEASE_DIR}/obj/local/armeabi-v7a/libpng.a)


### 3RDPARTY LINK ###
DKSET(PNG_WIN -DPNG_INCLUDE_DIR=${PNG} -DPNG_PNG_INCLUDE_DIR=${PNG}/${OS} -DPNG_INCLUDE_DIR2=${PNG}/${OS} -DPNG_LIBRARY_DEBUG=${PNG}/${OS}/${DEBUG_DIR}/libpng${PNG_MAJOR}${PNG_MINOR}_staticd.lib -DPNG_LIBRARY_RELEASE=${PNG}/${OS}/${RELEASE_DIR}/libpng${PNG_MAJOR}${PNG_MINOR}_static.lib)
DKSET(PNG_APPLE -DPNG_INCLUDE_DIR=${PNG} -DPNG_INCLUDE_DIR2=${PNG}/${OS} -DPNG_LIBRARY_DEBUG=${PNG}/${OS}/${DEBUG_DIR}/libpng${PNG_MAJOR}${PNG_MINOR}d.a -DPNG_LIBRARY_RELEASE=${PNG}/${OS}/${RELEASE_DIR}/libpng${PNG_MAJOR}${PNG_MINOR}.a)
DKSET(PNG_LINUX -DPNG_INCLUDE_DIR=${PNG} -DPNG_INCLUDE_DIR2=${PNG}/${OS}/${RELEASE_DIR} -DPNG_LIBRARY_DEBUG=${PNG}/${OS}/${DEBUG_DIR}/libpng${PNG_MAJOR}${PNG_MINOR}d.a -DPNG_LIBRARY_RELEASE=${PNG}/${OS}/${RELEASE_DIR}/libpng${PNG_MAJOR}${PNG_MINOR}.a)
DKSET(PNG_RASPBERRY -DPNG_INCLUDE_DIR=${PNG} -DPNG_INCLUDE_DIR2=${PNG}/${OS} -DPNG_LIBRARY_DEBUG=${PNG}/${OS}/${DEBUG_DIR}/libpng${PNG_MAJOR}${PNG_MINOR}d.a -DPNG_LIBRARY_RELEASE=${PNG}/${OS}/${RELEASE_DIR}/libpng${PNG_MAJOR}${PNG_MINOR}.a)
DKSET(PNG_ANDROID -DPNG_INCLUDE_DIR=${PNG} -DPNG_INCLUDE_DIR2=${PNG}/${OS} -DPNG_LIBRARY_DEBUG=${PNG}/${OS}/${DEBUG_DIR}/libpng${PNG_MAJOR}${PNG_MINOR}d.a -DPNG_LIBRARY_RELEASE=${PNG}/${OS}/${RELEASE_DIR}/libpng${PNG_MAJOR}${PNG_MINOR}.a)
	

### COMPILE ###
WIN_PATH(${PNG}/${OS})
WIN32_COMMAND(${DKCMAKE_WIN32} -DPNG_SHARED=OFF -DPNG_TESTS=OFF ${ZLIB_WIN} ${PNG})
WIN64_COMMAND(${DKCMAKE_WIN64} -DPNG_SHARED=OFF -DPNG_TESTS=OFF ${ZLIB_WIN} ${PNG})
WIN_VS(${PNG_NAME} libpng.sln png${PNG_MAJOR}${PNG_MINOR}_static)


MAC_PATH(${PNG}/${OS})
MAC32_COMMAND(${DKCMAKE_MAC32} -DPNG_SHARED=OFF -DPNG_TESTS=OFF ${ZLIB_APPLE} ${PNG})
MAC64_COMMAND(${DKCMAKE_MAC64} -DPNG_SHARED=OFF -DPNG_TESTS=OFF ${ZLIB_APPLE} ${PNG})
MAC_XCODE(${PNG_NAME} png${PNG_MAJOR}${PNG_MINOR}_static)


IOS_PATH(${PNG}/${OS})
IOS64_COMMAND(${DKCMAKE_IOS64} -DPNG_SHARED=OFF -DPNG_TESTS=OFF ${ZLIB_APPLE} ${PNG})
IOS_XCODE(${PNG_NAME} png${PNG_MAJOR}${PNG_MINOR}_static)


IOS_PATH(${PNG}/${OS})
IOSSIM64_COMMAND(${DKCMAKE_IOSSIM64} -DPNG_SHARED=OFF -DPNG_TESTS=OFF ${ZLIB_APPLE} ${PNG})
IOSSIM_XCODE(${PNG_NAME} png${PNG_MAJOR}${PNG_MINOR}_static)


LINUX_DEBUG_PATH(${PNG}/${OS}/${DEBUG_DIR})
LINUX_DEBUG_COMMAND(${DKCMAKE_LINUX_DEBUG} -DPNG_SHARED=OFF -DPNG_TESTS=ON ${ZLIB_LINUX} ${PNG})
LINUX_DEBUG_COMMAND(make all)

LINUX_RELEASE_PATH(${PNG}/${OS}/${RELEASE_DIR})
LINUX_RELEASE_COMMAND(${DKCMAKE_LINUX_RELEASE} -DPNG_SHARED=OFF -DPNG_TESTS=ON ${ZLIB_LINUX} ${PNG})
LINUX_RELEASE_COMMAND(make all)


RASPBERRY_DEBUG_PATH(${PNG}/${OS}/${DEBUG_DIR})
RASPBERRY_DEBUG_COMMAND(${DKCMAKE_RASPBERRY_DEBUG} -DPNG_SHARED=OFF -DPNG_TESTS=ON ${ZLIB_RASPBERRY} ${PNG})
RASPBERRY_DEBUG_COMMAND(make all)

RASPBERRY_RELEASE_PATH(${PNG}/${OS}/${RELEASE_DIR})
RASPBERRY_RELEASE_COMMAND(${DKCMAKE_RASPBERRY_RELEASE} -DPNG_SHARED=OFF -DPNG_TESTS=ON ${ZLIB_RASPBERRY} ${PNG})
RASPBERRY_RELEASE_COMMAND(make all)


##ANDROID_NDK(${PNG_NAME})
ANDROID_PATH(${PNG}/${OS})
ANDROID32_COMMAND(${DKCMAKE_ANDROID32} -DPNG_SHARED=OFF -DPNG_TESTS=OFF ${ZLIB_ANDOID} ${PNG})
ANDROID64_COMMAND(${DKCMAKE_ANDROID64} -DPNG_SHARED=OFF -DPNG_TESTS=OFF ${ZLIB_ANDOID} ${PNG})
ANDROID_VS(${PNG_NAME} libpng.sln png${PNG_MAJOR}${PNG_MINOR}_static)