aboutsummaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake')
-rw-r--r--cmake/toolchain.android.cmake43
1 files changed, 30 insertions, 13 deletions
diff --git a/cmake/toolchain.android.cmake b/cmake/toolchain.android.cmake
index 70aa6248..178b9273 100644
--- a/cmake/toolchain.android.cmake
+++ b/cmake/toolchain.android.cmake
@@ -37,19 +37,23 @@ if(NOT EXISTS "${ANDROID_NDK}")
endif()
if(EXISTS "${ANDROID_NDK}")
- if(APPLE)
- set(ANDROID_TOOLCHAIN_SYSTEM "darwin-x86")
- elseif(WIN32)
- set(ANDROID_TOOLCHAIN_SYSTEM "windows")
- set(TOOL_OS_SUFFIX ".exe")
- elseif(UNIX)
- set(ANDROID_TOOLCHAIN_SYSTEM "linux-x86")
- else()
- message(FATAL_ERROR "Your platform is not supported")
- endif()
+ if(NOT DEFINED ANDROID_TOOLCHAIN_SYSTEM)
+ if(APPLE)
+ set(ANDROID_TOOLCHAIN_SYSTEM "darwin-x86")
+ elseif(WIN32)
+ set(ANDROID_TOOLCHAIN_SYSTEM "windows")
+ set(TOOL_OS_SUFFIX ".exe")
+ elseif(UNIX)
+ set(ANDROID_TOOLCHAIN_SYSTEM "linux-x86")
+ else()
+ message(FATAL_ERROR "Your platform is not supported")
+ endif()
+ endif()
if(NOT ANDROID_API_LEVEL GREATER 2)
- if(NDK_CPU_X86)
+ if(NDK_CPU_ARM64)
+ set(ANDROID_API_LEVEL 21)
+ elseif(NDK_CPU_X86)
set(ANDROID_API_LEVEL 9)
else()
set(ANDROID_API_LEVEL 5)
@@ -62,6 +66,10 @@ if(EXISTS "${ANDROID_NDK}")
set(ANDROID_TOOLCHAIN_PREFIX "i686-android-linux")
set(ANDROID_TOOLCHAIN_NAME "x86")
set(ANDROID_TOOLCHAIN_PLATFORM_NAME "x86")
+ elseif(NDK_CPU_ARM64)
+ set(ANDROID_TOOLCHAIN_PREFIX "aarch64-linux-android")
+ set(ANDROID_TOOLCHAIN_NAME "${ANDROID_TOOLCHAIN_PREFIX}")
+ set(ANDROID_TOOLCHAIN_PLATFORM_NAME "arm64")
else()
set(ANDROID_TOOLCHAIN_PREFIX "arm-linux-androideabi")
set(ANDROID_TOOLCHAIN_NAME "${ANDROID_TOOLCHAIN_PREFIX}")
@@ -69,7 +77,7 @@ if(EXISTS "${ANDROID_NDK}")
endif()
if (NOT DEFINED ANDROID_TOOLCHAIN_VERSION)
- set(SUPPORTED_TOOLCHAIN_VERSIONS 4.4.0 4.4.3 4.6.0 4.6.1 4.6.2 4.6.3 4.7)
+ set(SUPPORTED_TOOLCHAIN_VERSIONS 4.4.0 4.4.3 4.6.0 4.6.1 4.6.2 4.6.3 4.7 4.8 4.9)
foreach(gcc_version ${SUPPORTED_TOOLCHAIN_VERSIONS})
if (EXISTS "${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}-${gcc_version}")
set(ANDROID_TOOLCHAIN_VERSION ${gcc_version})
@@ -104,6 +112,11 @@ set(CMAKE_RANLIB "${ANDROID_NDK_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_PR
if(NDK_CPU_X86)
set(ANDROID_NDK_CPU_NAME "x86")
set(CMAKE_SYSTEM_PROCESSOR "x86")
+elseif(NDK_CPU_ARM64)
+ set(NDK_CPU_ARM true)
+ set(ANDROID_NDK_CPU_NAME "arm64-v8a")
+ set(NDK_CPU_ARM_NEON false)
+ set(CMAKE_SYSTEM_PROCESSOR "armv8-a")
elseif(NDK_CPU_ARM_V7A)
set(NDK_CPU_ARM_NEON false)
set(NDK_CPU_ARM_VFPV3 false)
@@ -119,7 +132,7 @@ endif()
set(CMAKE_FIND_ROOT_PATH "${ANDROID_NDK_TOOLCHAIN_ROOT}/bin" "${ANDROID_NDK_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_PREFIX}" "${ANDROID_NDK_SYSROOT}" "${CMAKE_INSTALL_PREFIX}" "${CMAKE_INSTALL_PREFIX}/share")
-set(STL_PATH "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++")
+set(STL_PATH "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_TOOLCHAIN_VERSION}")
set(STL_LIBRARIES_PATH "${STL_PATH}/libs/${ANDROID_NDK_CPU_NAME}")
include_directories(SYSTEM "${STL_PATH}/include" "${STL_LIBRARIES_PATH}/include")
link_directories("${ANDROID_NDK_SYSROOT}/usr/lib")
@@ -133,6 +146,8 @@ set(CMAKE_CXX_FLAGS "-fPIC -DANDROID -Wno-psabi -fsigned-char -I${ANDROID_NDK_SY
set(FORCE_ARM OFF CACHE BOOL "Use 32-bit ARM instructions instead of Thumb-1")
if(NDK_CPU_X86)
+elseif(NDK_CPU_ARM64)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv8-a -std=c99")
elseif(NOT FORCE_ARM)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mthumb")
else()
@@ -152,6 +167,8 @@ if(NDK_CPU_ARM_V7A)
elseif(NDK_CPU_ARM_VFPV3)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=vfpv3")
endif()
+elseif(NDK_CPU_ARM64)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mabi=lp64 -mlittle-endian -march=armv8-a -std=c99")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "c++ flags")