• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1if (NOT DEFINED ANDROID_NDK_HOME)
2  if (DEFINED ENV{ANDROID_NDK_HOME})
3    set(ANDROID_NDK_HOME $ENV{ANDROID_NDK_HOME})
4  else ()
5    message(FATAL_ERROR "Missing required ANDROID_NDK_HOME option/env. Use -DANDROID_NDK_HOME=...")
6  endif ()
7endif ()
8
9set(ANDROID_BUILD_DIR "${CMAKE_SOURCE_DIR}/build_android")
10set(ANDROID_LIBS_DIR "${CMAKE_CURRENT_BINARY_DIR}/libs")
11
12foreach (AABI IN ITEMS ${ANDROID_ABIS})
13  list(APPEND ANDROID_ABIS_LIBS "${ANDROID_LIBS_DIR}/${AABI}/libejdb2jni.so")
14  add_custom_target(
15    android_${AABI} ALL
16    BYPRODUCTS ${ANDROID_LIBS_DIR}/${AABI}/libejdb2jni.so
17    COMMAND ${CMAKE_COMMAND} -E remove_directory ${ANDROID_BUILD_DIR}
18    COMMAND ${CMAKE_COMMAND} -E make_directory ${ANDROID_BUILD_DIR}
19    COMMAND ${CMAKE_COMMAND} -G ${CMAKE_GENERATOR} -S ${CMAKE_SOURCE_DIR}
20    -B ${ANDROID_BUILD_DIR}
21    -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
22    -DBUILD_JNI_BINDING=ON
23    -DENABLE_HTTP=OFF
24    -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake
25    -DANDROID_ABI=${AABI}
26    -DANDROID_PLATFORM=android-21
27    -DANDROID_NATIVE_API_LEVEL=21
28    -DIOWOW_URL=${IOWOW_URL}
29    COMMAND ${CMAKE_COMMAND} --build ${ANDROID_BUILD_DIR}
30    COMMAND ${CMAKE_COMMAND} -E make_directory ${ANDROID_LIBS_DIR}/${AABI}
31    COMMAND ${CMAKE_COMMAND} -E copy ${ANDROID_BUILD_DIR}/src/bindings/ejdb2_jni/src/libejdb2jni.so ${ANDROID_LIBS_DIR}/${AABI}
32    COMMAND ${CMAKE_COMMAND} -E copy ${ANDROID_BUILD_DIR}/src/bindings/ejdb2_jni/src/ejdb2.jar ${ANDROID_LIBS_DIR}
33    COMMAND ${CMAKE_COMMAND} -E remove_directory ${ANDROID_BUILD_DIR}
34    VERBATIM
35  )
36endforeach ()