Merge pull request #901 from Sonicadvance1/64bit-android-cmake

Update the android cmake toolchain file to support 64bit.
This commit is contained in:
shuffle2 2014-09-03 00:09:03 -07:00
commit 60a772c5e8
1 changed files with 105 additions and 38 deletions

View File

@ -85,10 +85,16 @@
# "armeabi-v7a with VFPV3" - same as armeabi-v7a, but
# sets VFPV3 as floating-point unit (has 32 registers instead of 16).
# "armeabi-v6 with VFP" - tuned for ARMv6 processors having VFP.
# "arm64-v8a" - matches to the NDK ABI with the same name.
# See ${ANDROID_NDK}/docs/CPU-ARCH-ABIS.html for the documentation.
# "x86" - matches to the NDK ABI with the same name.
# See ${ANDROID_NDK}/docs/CPU-ARCH-ABIS.html for the documentation.
# "x86_64" - matches to the NDK ABI with the same name.
# See ${ANDROID_NDK}/docs/CPU-ARCH-ABIS.html for the documentation.
# "mips" - matches to the NDK ABI with the same name.
# See ${ANDROID_NDK}/docs/CPU-ARCH-ABIS.html for the documentation.
# "mips64" - matches to the NDK ABI with the same name.
# See ${ANDROID_NDK}/docs/CPU-ARCH-ABIS.html for the documentation.
#
# ANDROID_NATIVE_API_LEVEL=android-8 - level of Android API compile for.
# Option is read-only when standalone toolchain is used.
@ -181,7 +187,7 @@
# ANDROID and BUILD_ANDROID will be set to true, you may test any of these
# variables to make necessary Android-specific configuration changes.
#
# Also ARMEABI or ARMEABI_V7A or X86 or MIPS will be set true, mutually
# Also ARMEABI or ARMEABI_V7A or ARM64_V8A or X86 or X86_64 or MIPS or MIPS64 will be set true, mutually
# exclusive. NEON option will be set true if VFP is set to NEON.
#
# LIBRARY_OUTPUT_PATH_ROOT should be set in cache to determine where Android
@ -301,6 +307,11 @@
# [+] updated for NDK r9c
# - January 2014
# [~] fix copying of shared STL
# - April 2014
# [+] updated for NDK r9d
# - July 2014
# [+] updated for NDK r10
# [+] arm64_v8a, x86_64, mips64 toolchain support (experimental)
# ------------------------------------------------------------------------------
cmake_minimum_required( VERSION 2.6.3 )
@ -327,7 +338,7 @@ set( CMAKE_SYSTEM_VERSION 1 )
# rpath makes low sence for Android
set( CMAKE_SKIP_RPATH TRUE CACHE BOOL "If set, runtime paths are not added when using shared libraries." )
set( ANDROID_SUPPORTED_NDK_VERSIONS ${ANDROID_EXTRA_NDK_VERSIONS} -r9c -r9b -r9 -r8e -r8d -r8c -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" )
set( ANDROID_SUPPORTED_NDK_VERSIONS ${ANDROID_EXTRA_NDK_VERSIONS} -r10 -r9d -r9c -r9b -r9 -r8e -r8d -r8c -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" )
if(NOT DEFINED ANDROID_NDK_SEARCH_PATHS)
if( CMAKE_HOST_WIN32 )
file( TO_CMAKE_PATH "$ENV{PROGRAMFILES}" ANDROID_NDK_SEARCH_PATHS )
@ -342,12 +353,18 @@ if(NOT DEFINED ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH)
endif()
set( ANDROID_SUPPORTED_ABIS_arm "armeabi-v7a;armeabi;armeabi-v7a with NEON;armeabi-v7a with VFPV3;armeabi-v6 with VFP" )
set( ANDROID_SUPPORTED_ABIS_arm64 "arm64-v8a" )
set( ANDROID_SUPPORTED_ABIS_x86 "x86" )
set( ANDROID_SUPPORTED_ABIS_x86_64 "x86_64" )
set( ANDROID_SUPPORTED_ABIS_mipsel "mips" )
set( ANDROID_SUPPORTED_ABIS_mips64el "mips64" )
set( ANDROID_DEFAULT_NDK_API_LEVEL 8 )
set( ANDROID_DEFAULT_NDK_API_LEVEL_x86 9 )
set( ANDROID_DEFAULT_NDK_API_LEVEL_mips 9 )
set( ANDROID_DEFAULT_NDK_API_LEVEL_arm64 "L" )
set( ANDROID_DEFAULT_NDK_API_LEVEL_x86_64 "L" )
set( ANDROID_DEFAULT_NDK_API_LEVEL_mips64 "L" )
macro( __LIST_FILTER listvar regex )
@ -651,10 +668,16 @@ macro( __GLOB_NDK_TOOLCHAINS __availableToolchainsVar __availableToolchainsLst _
string( REGEX MATCH "[0-9]+[.][0-9]+([.][0-9x]+)?$" __version "${__gcc_toolchain}" )
if( __machine MATCHES i686 )
set( __arch "x86" )
elseif( __machine MATCHES x86_64 )
set( __arch "x86_64" )
elseif( __machine MATCHES arm )
set( __arch "arm" )
elseif( __machine MATCHES aarch64 )
set( __arch "arm64" )
elseif( __machine MATCHES mipsel )
set( __arch "mipsel" )
elseif( __machine MATCHES mips64el )
set( __arch "mips64el" )
endif()
list( APPEND __availableToolchainMachines "${__machine}" )
list( APPEND __availableToolchainArchs "${__arch}" )
@ -738,6 +761,13 @@ if( ANDROID_ABI STREQUAL "x86" )
set( ANDROID_ARCH_FULLNAME "x86" )
set( ANDROID_LLVM_TRIPLE "i686-none-linux-android" )
set( CMAKE_SYSTEM_PROCESSOR "i686" )
elseif( ANDROID_ABI STREQUAL "x86_64" )
set( X86_64 true )
set( ANDROID_NDK_ABI_NAME "x86_64" )
set( ANDROID_ARCH_NAME "x86_64" )
set( ANDROID_ARCH_FULLNAME "x86_64" )
set( ANDROID_LLVM_TRIPLE "x86_64-none-linux-android" )
set( CMAKE_SYSTEM_PROCESSOR "x86_64" )
elseif( ANDROID_ABI STREQUAL "mips" )
set( MIPS true )
set( ANDROID_NDK_ABI_NAME "mips" )
@ -745,6 +775,13 @@ elseif( ANDROID_ABI STREQUAL "mips" )
set( ANDROID_ARCH_FULLNAME "mipsel" )
set( ANDROID_LLVM_TRIPLE "mipsel-none-linux-android" )
set( CMAKE_SYSTEM_PROCESSOR "mips" )
elseif( ANDROID_ABI STREQUAL "mips64" )
set( MIPS64 true )
set( ANDROID_NDK_ABI_NAME "mips64" )
set( ANDROID_ARCH_NAME "mips64" )
set( ANDROID_ARCH_FULLNAME "mips64el" )
set( ANDROID_LLVM_TRIPLE "mips64el-none-linux-android" )
set( CMAKE_SYSTEM_PROCESSOR "mips64" )
elseif( ANDROID_ABI STREQUAL "armeabi" )
set( ARMEABI true )
set( ANDROID_NDK_ABI_NAME "armeabi" )
@ -785,6 +822,15 @@ elseif( ANDROID_ABI STREQUAL "armeabi-v7a with NEON" )
set( CMAKE_SYSTEM_PROCESSOR "armv7-a" )
set( VFPV3 true )
set( NEON true )
elseif( ANDROID_ABI STREQUAL "arm64-v8a" )
set( ARM64_V8A true )
set( ANDROID_NDK_ABI_NAME "arm64-v8a" )
set( ANDROID_ARCH_NAME "arm64" )
set( ANDROID_ARCH_FULLNAME "arm64" )
set( ANDROID_LLVM_TRIPLE "armv8-none-linux-androideabi" )
set( CMAKE_SYSTEM_PROCESSOR "aarch64" )
set( VFPV3 true )
set( NEON true )
else()
message( SEND_ERROR "Unknown ANDROID_ABI=\"${ANDROID_ABI}\" is specified." )
endif()
@ -854,38 +900,40 @@ unset( __availableToolchainCompilerVersions )
# choose native API level
__INIT_VARIABLE( ANDROID_NATIVE_API_LEVEL ENV_ANDROID_NATIVE_API_LEVEL ANDROID_API_LEVEL ENV_ANDROID_API_LEVEL ANDROID_STANDALONE_TOOLCHAIN_API_LEVEL ANDROID_DEFAULT_NDK_API_LEVEL_${ANDROID_ARCH_NAME} ANDROID_DEFAULT_NDK_API_LEVEL )
string( REGEX MATCH "[0-9]+" ANDROID_NATIVE_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}" )
# adjust API level
set( __real_api_level ${ANDROID_DEFAULT_NDK_API_LEVEL_${ANDROID_ARCH_NAME}} )
foreach( __level ${ANDROID_SUPPORTED_NATIVE_API_LEVELS} )
if( NOT __level GREATER ANDROID_NATIVE_API_LEVEL AND NOT __level LESS __real_api_level )
set( __real_api_level ${__level} )
endif()
endforeach()
if( __real_api_level AND NOT ANDROID_NATIVE_API_LEVEL EQUAL __real_api_level )
message( STATUS "Adjusting Android API level 'android-${ANDROID_NATIVE_API_LEVEL}' to 'android-${__real_api_level}'")
set( ANDROID_NATIVE_API_LEVEL ${__real_api_level} )
endif()
unset(__real_api_level)
# validate
list( FIND ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_NATIVE_API_LEVEL}" __levelIdx )
if( __levelIdx EQUAL -1 )
message( SEND_ERROR "Specified Android native API level 'android-${ANDROID_NATIVE_API_LEVEL}' is not supported by your NDK/toolchain." )
else()
if( BUILD_WITH_ANDROID_NDK )
__DETECT_NATIVE_API_LEVEL( __realApiLevel "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/include/android/api-level.h" )
if( NOT __realApiLevel EQUAL ANDROID_NATIVE_API_LEVEL )
message( SEND_ERROR "Specified Android API level (${ANDROID_NATIVE_API_LEVEL}) does not match to the level found (${__realApiLevel}). Probably your copy of NDK is broken." )
if( NOT ANDROID_NATIVE_API_LEVEL STREQUAL "L" )
string( REGEX MATCH "[0-9]+" ANDROID_NATIVE_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}" )
# adjust API level
set( __real_api_level ${ANDROID_DEFAULT_NDK_API_LEVEL_${ANDROID_ARCH_NAME}} )
foreach( __level ${ANDROID_SUPPORTED_NATIVE_API_LEVELS} )
if( NOT __level GREATER ANDROID_NATIVE_API_LEVEL AND NOT __level LESS __real_api_level )
set( __real_api_level ${__level} )
endif()
endforeach()
if( __real_api_level AND NOT ANDROID_NATIVE_API_LEVEL EQUAL __real_api_level )
message( STATUS "Adjusting Android API level 'android-${ANDROID_NATIVE_API_LEVEL}' to 'android-${__real_api_level}'")
set( ANDROID_NATIVE_API_LEVEL ${__real_api_level} )
endif()
unset(__real_api_level)
# validate
list( FIND ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_NATIVE_API_LEVEL}" __levelIdx )
if( __levelIdx EQUAL -1 )
message( SEND_ERROR "Specified Android native API level 'android-${ANDROID_NATIVE_API_LEVEL}' is not supported by your NDK/toolchain." )
else()
if( BUILD_WITH_ANDROID_NDK )
__DETECT_NATIVE_API_LEVEL( __realApiLevel "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/include/android/api-level.h" )
if( NOT __realApiLevel EQUAL ANDROID_NATIVE_API_LEVEL )
message( SEND_ERROR "Specified Android API level (${ANDROID_NATIVE_API_LEVEL}) does not match to the level found (${__realApiLevel}). Probably your copy of NDK is broken." )
endif()
unset( __realApiLevel )
endif()
set( ANDROID_NATIVE_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}" CACHE STRING "Android API level for native code" FORCE )
if( CMAKE_VERSION VERSION_GREATER "2.8" )
list( SORT ANDROID_SUPPORTED_NATIVE_API_LEVELS )
set_property( CACHE ANDROID_NATIVE_API_LEVEL PROPERTY STRINGS ${ANDROID_SUPPORTED_NATIVE_API_LEVELS} )
endif()
endif()
unset( __realApiLevel )
endif()
set( ANDROID_NATIVE_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}" CACHE STRING "Android API level for native code" FORCE )
if( CMAKE_VERSION VERSION_GREATER "2.8" )
list( SORT ANDROID_SUPPORTED_NATIVE_API_LEVELS )
set_property( CACHE ANDROID_NATIVE_API_LEVEL PROPERTY STRINGS ${ANDROID_SUPPORTED_NATIVE_API_LEVELS} )
endif()
unset( __levelIdx )
endif()
unset( __levelIdx )
# remember target ABI
@ -1206,7 +1254,11 @@ if( ANDROID_COMPILER_IS_CLANG )
set( CMAKE_C_COMPILER_ID Clang)
endif()
set( CMAKE_C_PLATFORM_ID Linux )
set( CMAKE_C_SIZEOF_DATA_PTR 4 )
if( ARM64_V8A OR X86_64 OR MIPS64 )
set( CMAKE_C_SIZEOF_DATA_PTR 4 )
else()
set( CMAKE_C_SIZEOF_DATA_PTR 8 )
endif()
set( CMAKE_C_HAS_ISYSROOT 1 )
set( CMAKE_C_COMPILER_ABI ELF )
CMAKE_FORCE_CXX_COMPILER( "${CMAKE_CXX_COMPILER}" GNU )
@ -1214,7 +1266,11 @@ if( ANDROID_COMPILER_IS_CLANG )
set( CMAKE_CXX_COMPILER_ID Clang)
endif()
set( CMAKE_CXX_PLATFORM_ID Linux )
set( CMAKE_CXX_SIZEOF_DATA_PTR 4 )
if( ARM64_V8A OR X86_64 OR MIPS64 )
set( CMAKE_CXX_SIZEOF_DATA_PTR 4 )
else()
set( CMAKE_CXX_SIZEOF_DATA_PTR 8 )
endif()
set( CMAKE_CXX_HAS_ISYSROOT 1 )
set( CMAKE_CXX_COMPILER_ABI ELF )
set( CMAKE_CXX_SOURCE_FILE_EXTENSIONS cc cp cxx cpp CPP c++ C )
@ -1271,7 +1327,7 @@ if( ARMEABI OR ARMEABI_V7A )
set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funswitch-loops -finline-limit=300" )
endif()
endif()
elseif( X86 )
elseif( X86 OR X86_64 )
set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funwind-tables" )
if( NOT ANDROID_COMPILER_IS_CLANG )
set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funswitch-loops -finline-limit=300" )
@ -1280,7 +1336,7 @@ elseif( X86 )
endif()
set( ANDROID_CXX_FLAGS_RELEASE "-fomit-frame-pointer -fstrict-aliasing" )
set( ANDROID_CXX_FLAGS_DEBUG "-fno-omit-frame-pointer -fno-strict-aliasing" )
elseif( MIPS )
elseif( MIPS OR MIPS64 )
set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fpic -fno-strict-aliasing -finline-functions -ffunction-sections -funwind-tables -fmessage-length=0" )
set( ANDROID_CXX_FLAGS_RELEASE "-fomit-frame-pointer" )
set( ANDROID_CXX_FLAGS_DEBUG "-fno-omit-frame-pointer" )
@ -1317,6 +1373,8 @@ elseif( ARMEABI_V6 )
set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv6 -mfloat-abi=softfp -mfpu=vfp" ) # vfp == vfpv2
elseif( ARMEABI )
set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv5te -mtune=xscale -msoft-float" )
elseif( ARM64_V8A )
set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv8-a" )
endif()
if( ANDROID_STL MATCHES "gnustl" AND (EXISTS "${__libstl}" OR EXISTS "${__libsupcxx}") )
@ -1631,10 +1689,16 @@ macro( ANDROID_GET_ABI_RAWNAME TOOLCHAIN_FLAG VAR )
set( ${VAR} "armeabi" )
elseif( "${TOOLCHAIN_FLAG}" STREQUAL "ARMEABI_V7A" )
set( ${VAR} "armeabi-v7a" )
elseif( "${TOOLCHAIN_FLAG}" STREQUAL "ARM64_V8A" )
set( ${VAR} "arm64-v8a" )
elseif( "${TOOLCHAIN_FLAG}" STREQUAL "X86" )
set( ${VAR} "x86" )
elseif( "${TOOLCHAIN_FLAG}" STREQUAL "X86_64" )
set( ${VAR} "x86_64" )
elseif( "${TOOLCHAIN_FLAG}" STREQUAL "MIPS" )
set( ${VAR} "mips" )
elseif( "${TOOLCHAIN_FLAG}" STREQUAL "MIPS64" )
set( ${VAR} "mips64" )
else()
set( ${VAR} "unknown" )
endif()
@ -1701,7 +1765,7 @@ endif()
# Variables controlling behavior or set by cmake toolchain:
# ANDROID_ABI : "armeabi-v7a" (default), "armeabi", "armeabi-v7a with NEON", "armeabi-v7a with VFPV3", "armeabi-v6 with VFP", "x86", "mips"
# ANDROID_ABI : "armeabi-v7a" (default), "armeabi", "armeabi-v7a with NEON", "armeabi-v7a with VFPV3", "armeabi-v6 with VFP", "arm64-v8a", "x86", "x86_64", "mips", "mips64"
# ANDROID_NATIVE_API_LEVEL : 3,4,5,8,9,14 (depends on NDK version)
# ANDROID_STL : gnustl_static/gnustl_shared/stlport_static/stlport_shared/gabi++_static/gabi++_shared/system_re/system/none
# ANDROID_FORBID_SYGWIN : ON/OFF
@ -1735,16 +1799,19 @@ endif()
# ARMEABI : TRUE for arm v6 and older devices
# ARMEABI_V6 : TRUE for arm v6
# ARMEABI_V7A : TRUE for arm v7a
# ARM64_V8A : TRUE for arm64 v8a
# NEON : TRUE if NEON unit is enabled
# VFPV3 : TRUE if VFP version 3 is enabled
# X86 : TRUE if configured for x86
# X86_64 : TRUE if configured for x86_64
# MIPS : TRUE if configured for mips
# MIPS64 : TRUE if configured for mips64
# BUILD_ANDROID : always TRUE
# BUILD_WITH_ANDROID_NDK : TRUE if NDK is used
# BUILD_WITH_STANDALONE_TOOLCHAIN : TRUE if standalone toolchain is used
# ANDROID_NDK_HOST_SYSTEM_NAME : "windows", "linux-x86" or "darwin-x86" depending on host platform
# ANDROID_NDK_ABI_NAME : "armeabi", "armeabi-v7a", "x86" or "mips" depending on ANDROID_ABI
# ANDROID_NDK_RELEASE : one of r5, r5b, r5c, r6, r6b, r7, r7b, r7c, r8, r8b, r8c, r8d, r8e, r9, r9b, r9c; set only for NDK
# ANDROID_NDK_RELEASE : one of r5, r5b, r5c, r6, r6b, r7, r7b, r7c, r8, r8b, r8c, r8d, r8e, r9, r9b, r9c, r9d, r10; set only for NDK
# ANDROID_ARCH_NAME : "arm" or "x86" or "mips" depending on ANDROID_ABI
# ANDROID_SYSROOT : path to the compiler sysroot
# TOOL_OS_SUFFIX : "" or ".exe" depending on host platform