# Defines the following variables:
#
#   ANDROID_FOUND - Found the ANDROID NDK library
#   ANDROID_SYSROOT - Location of the ANDROID NDK sysroot
#   ANDROID_INCLUDE_DIRS - Include directories for ANDROID NDK
#   ANDROID_LINK_DIRS - Link directories for ANDROID NDK
#   ANDROID_LIBRARIES - The ANDROID NDK libraries

set(ANDROID_FOUND "TRUE")

set(ANDROID_TOOLCHAIN_PATH ${TOOLCHAIN_PATH}/android/ndk)
set(ANDROID_SYSROOT ${ANDROID_TOOLCHAIN_PATH}/sysroot)

set(ANDROID_INCLUDE_DIRS ${ANDROID_SYSROOT}/usr/include)
set(ANDROID_LINK_DIRS ${ANDROID_SYSROOT}/usr/lib)
set(ANDROID_LIBRARIES "android")

list(APPEND ANDROID_LIBRARIES jnigraphics)
list(APPEND ANDROID_LIBRARIES log)
list(APPEND ANDROID_LIBRARIES EGL)
list(APPEND ANDROID_LIBRARIES GLESv1_CM)
list(APPEND ANDROID_LIBRARIES GLESv2)
list(APPEND ANDROID_LIBRARIES GLESv3)
list(APPEND ANDROID_LIBRARIES dl)
list(APPEND ANDROID_LIBRARIES m)
list(APPEND ANDROID_LIBRARIES z)

# Convert to absolute library paths
set(ANDROID_LIBRARIES_ABS "")
foreach(_l ${ANDROID_LIBRARIES})
    find_library(ANDROID_lib${_l} NAMES ${_l}
        PATHS ${ANDROID_LINK_DIRS} ${TARGET_PATH}/lib NO_DEFAULT_PATH)
    list(APPEND ANDROID_LIBRARIES_ABS ${ANDROID_lib${_l}})
endforeach()

set(ANDROID_LIBRARIES ${ANDROID_LIBRARIES_ABS})
