Skip to content

Instantly share code, notes, and snippets.

@zoobab
Created December 14, 2015 08:49
Show Gist options
  • Save zoobab/092b109ccd066ce8bfae to your computer and use it in GitHub Desktop.
Save zoobab/092b109ccd066ce8bfae to your computer and use it in GitHub Desktop.
android_toolchain.cmake
# copy me to czmq/bindings/jni/android_toolchain.cmake
set(CMAKE_SYSTEM_NAME Linux) # Tell CMake we're cross-compiling
set(ANDROID_NDK /opt/android-ndk)
include(CMakeForceCompiler)
# Prefix detection only works with compiler id "GNU"
# CMake will look for prefixed g++, cpp, ld, etc. automatically
CMAKE_FORCE_C_COMPILER(arm-linux-androideabi-gcc GNU)
set(ANDROID True)
set(BUILD_ANDROID True)
include_directories (../.././builds/qt-android/prefix/arm-linux-androideabi-4.9/include /opt/android-ndk/platforms/android-8/arch-arm/usr/include ../../include)
# where is the target environment
set(ANDROID_TOOLCHAIN_ROOT ${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64)
set(ANDROID_TOOLCHAIN_MACHINE_NAME arm-linux-androideabi)
# api level see doc https://github.com/taka-no-me/android-cmake
set(ANDROID_NATIVE_API_LEVEL android-8)
set(ANDROID_ARCH_NAME arm)
set(ANDROID_SYSROOT "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}" )
set(CMAKE_INSTALL_PREFIX /tmp)
set(CMAKE_FIND_ROOT_PATH "${ANDROID_TOOLCHAIN_ROOT}/bin" "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}" "${ANDROID_SYSROOT}" "${CMAKE_INSTALL_PREFIX}" "${CMAKE_INSTALL_PREFIX}/share")
# only search for libraries and includes in the ndk toolchain
#set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
#set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
#set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment