#
# https://stackoverflow.com/a/57734435/688352
#
# https://ftp.gnu.org/gnu/libiconv/libiconv-1.14.tar.gz
# https://web.archive.org/web/20210126135625if_/http://ftp.gnu.org/gnu/libiconv/libiconv-1.14.tar.gz

### VERSION ###
DKSET(ICONV_VERSION 1.14)
DKSET(ICONV_NAME libiconv-${ICONV_VERSION})
DKSET(ICONV_DL https://ftp.gnu.org/gnu/libiconv/${ICONV_NAME}.tar.gz)
#DKSET(ICONV_DL https://web.archive.org/web/20210126135625if_/http://ftp.gnu.org/gnu/libiconv/${ICONV_NAME}.tar.gz)
DKSET(ICONV ${3RDPARTY}/${ICONV_NAME})


### INSTALL ###
DKINSTALL(${ICONV_DL} libiconv ${ICONV})



### LINK ###
DKINCLUDE(${ICONV})
DKINCLUDE(${ICONV}/include)
DKINCLUDE(${ICONV}/${OS})
DKINCLUDE(${ICONV}/${OS}/${RELEASE_DIR})
ANDROID_INCLUDE(${ICONV}/${OS}/$(BUILD_TYPE)/jni)
WIN_DEBUG_LIB(${ICONV}/${OS}/${DEBUG_DIR}/iconv.lib)
WIN_RELEASE_LIB(${ICONV}/${OS}/${RELEASE_DIR}/iconv.lib)
WIN_DEBUG_LIB(${ICONV}/${OS}/${DEBUG_DIR}/charset.lib)
WIN_RELEASE_LIB(${ICONV}/${OS}/${RELEASE_DIR}/charset.lib)
APPLE_DEBUG_LIB(${ICONV}/${OS}/${DEBUG_DIR}/libiconv.a)
APPLE_RELEASE_LIB(${ICONV}/${OS}/${RELEASE_DIR}/libiconv.a)
LINUX_DEBUG_LIB(${ICONV}/${OS}/${DEBUG_DIR}/libiconv.a)
LINUX_RELEASE_LIB(${ICONV}/${OS}/${RELEASE_DIR}/libiconv.a)
RASPBERRY_DEBUG_LIB(${ICONV}/${OS}/${DEBUG_DIR}/libiconv.a)
RASPBERRY_RELEASE_LIB(${ICONV}/${OS}/${RELEASE_DIR}/libiconv.a)
##ANDROID_DEBUG_LIB(${ICONV}/${OS}/${DEBUG_DIR}/obj/local/armeabi-v7a/libiconv.a)
##ANDROID_RELEASE_LIB(${ICONV}/${OS}/${RELEASE_DIR}/obj/local/armeabi-v7a/libiconv.a)
ANDROID_DEBUG_LIB(${ICONV}/${OS}/${DEBUG_DIR}/libiconv.a)
ANDROID_RELEASE_LIB(${ICONV}/${OS}/${RELEASE_DIR}/libiconv.a)


DKSET(ICONV_WIN -DICONV_DIR=${ICONV} -DICONV_LIBRARIES=${ICONV}/${OS}/${RELEASE_DIR} -DICONV_INCLUDE_DIR=${ICONV}/include)
DKSET(ICONV_APPLE "-DCMAKE_C_FLAGS=-I${ICONV}/include" -DICONV_DIR=${ICONV} -DICONV_LIBRARIES=${ICONV}/${OS}/${RELEASE_DIR} -DICONV_INCLUDE_DIR=${ICONV}/include)
DKSET(ICONV_LINUX -DICONV_DIR=${ICONV} -DICONV_LIBRARIES=${ICONV}/${OS}/${RELEASE_DIR} -DICONV_INCLUDE_DIR=${ICONV}/include)
DKSET(ICONV_ANDROID -DICONV_DIR=${ICONV} -DICONV_LIBRARIES=${ICONV}/${OS}/${RELEASE_DIR} -DICONV_INCLUDE_DIR=${ICONV}/include)


### COMPILE ###
WIN_PATH(${ICONV}/${OS})
WIN32_COMMAND(${DKCMAKE_WIN32} ${ICONV})
WIN64_COMMAND(${DKCMAKE_WIN64} ${ICONV})
WIN_VS(${ICONV_NAME} libiconv.sln iconv)


MAC_PATH(${ICONV}/${OS})
MAC32_COMMAND(${DKCMAKE_MAC32} ${ICONV})
MAC64_COMMAND(${DKCMAKE_MAC64} ${ICONV})
MAC_XCODE(${ICONV_NAME} iconv)


IOS_PATH(${ICONV}/${OS})
IOS64_COMMAND(${DKCMAKE_IOS64} ${ICONV})
IOS_XCODE(${ICONV_NAME} iconv)


IOSSIM_PATH(${ICONV}/${OS})
IOSSIM_COMMAND(${DKCMAKE_IOSSIM64} ${ICONV})
IOSSIM_XCODE(${ICONV_NAME} iconv)


LINUX_DEBUG_PATH(${ICONV}/${OS}/${DEBUG_DIR})
LINUX_DEBUG_COMMAND(${DKCMAKE_LINUX_DEBUG} ${ICONV})
LINUX_DEBUG_COMMAND(make iconv)

LINUX_RELEASE_PATH(${ICONV}/${OS}/${RELEASE_DIR})
LINUX_RELEASE_COMMAND(${DKCMAKE_LINUX_RELEASE} ${ICONV})
LINUX_RELEASE_COMMAND(make iconv)


RASPBERRY_DEBUG_PATH(${ICONV}/${OS}/${DEBUG_DIR})
RASPBERRY_DEBUG_COMMAND(${DKCMAKE_RASPBERRY_DEBUG} ${ICONV})
RASPBERRY_DEBUG_COMMAND(make iconv)

RASPBERRY_RELEASE_PATH(${ICONV}/${OS}/${RELEASE_DIR})
RASPBERRY_RELEASE_COMMAND(${DKCMAKE_RASPBERRY_RELEASE} ${ICONV})
RASPBERRY_RELEASE_COMMAND(make iconv)


##ANDROID_NDK(${ICONV_NAME})
ANDROID_PATH(${ICONV}/${OS})
ANDROID32_COMMAND(${DKCMAKE_ANDROID32} ${ICONV})
ANDROID64_COMMAND(${DKCMAKE_ANDROID64} ${ICONV})
ANDROID_VS(${ICONV_NAME} libiconv.sln iconv)