set(LFL_ANDROID 1)
set(JAVA_HOME $ENV{JAVA_HOME})
set(ANDROID_HOME $ENV{ANDROID_HOME})
set(GRADLE_HOME $ENV{GRADLE_HOME})

string(REGEX REPLACE "-[A-Za-z0-9]*-gcc$" "-gcc"
       ENV_CC ${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_NAME}-gcc)
string(REGEX REPLACE "-[A-Za-z0-9]*-g\\\\+\\\\+$" "-g\\\\+\\\\+"
       ENV_CXX ${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_NAME}-g++)
string(REGEX REPLACE "-[A-Za-z0-9]*-cpp$" "-cpp"
       ENV_CPP ${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_NAME}-cpp)
string(REGEX REPLACE "-[A-Za-z0-9]*-ld$" "-ld"
       ENV_LD ${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_NAME}-ld)
set(ENV_CFLAGS "--sysroot ${CMAKE_SYSROOT}")
set(CONFIGURE_ENV CC=${ENV_CC} CXX=${ENV_CXX} "CPP=${ENV_CPP} --sysroot ${CMAKE_SYSROOT}"
    AR=${CMAKE_AR} RANLIB=${CMAKE_RANLIB} CFLAGS=${ENV_CFLAGS} CXXFLAGS=${ENV_CFLAGS}
    LD=${ENV_LD} LDFLAGS=${ENV_CFLAGS})
if(ANDROID_ABI MATCHES "armeabi")
  set(CONFIGURE_OPTIONS "--host=arm")
elseif(ANDROID_ABI MATCHES "x86")
  set(CONFIGURE_OPTIONS "--host=x86")
endif()
set(CONFIGURE_CMAKE -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
    -DANDROID_ABI=${ANDROID_ABI} -DANDROID_NDK=${ANDROID_NDK}
    -DANDROID_NATIVE_API_LEVEL=${ANDROID_NATIVE_API_LEVEL})
