|
|
@@ -29,7 +29,7 @@
|
|
|
# POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
-# Android CMake toolchain file, for use with the Android NDK r5-r10c
|
|
|
+# Android CMake toolchain file, for use with the Android NDK r5-r10d
|
|
|
# Requires cmake 2.6.3 or newer (2.8.5 or newer is recommended).
|
|
|
# See home page: https://github.com/taka-no-me/android-cmake
|
|
|
#
|
|
|
@@ -248,7 +248,7 @@ set( CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "" )
|
|
|
set( CMAKE_SKIP_RPATH TRUE CACHE BOOL "If set, runtime paths are not added when using shared libraries." )
|
|
|
|
|
|
# NDK search paths
|
|
|
-set( ANDROID_SUPPORTED_NDK_VERSIONS ${ANDROID_EXTRA_NDK_VERSIONS} -r10c -r10b -r10 -r9d -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} -r10d -r10c -r10b -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 )
|
|
|
@@ -1080,7 +1080,7 @@ if( BUILD_WITH_ANDROID_NDK )
|
|
|
else()
|
|
|
set( __libstl "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++" )
|
|
|
endif()
|
|
|
- set( ANDROID_STL_INCLUDE_DIRS "${__libstl}/include" "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/include" )
|
|
|
+ set( ANDROID_STL_INCLUDE_DIRS "${__libstl}/include" "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/include" "${__libstl}/include/backward" )
|
|
|
if( EXISTS "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/libgnustl_static.a" )
|
|
|
set( __libstl "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/libgnustl_static.a" )
|
|
|
else()
|
|
|
@@ -1182,7 +1182,7 @@ endif()
|
|
|
include( CMakeForceCompiler )
|
|
|
CMAKE_FORCE_C_COMPILER( "${CMAKE_C_COMPILER}" GNU )
|
|
|
if( ANDROID_COMPILER_IS_CLANG )
|
|
|
- set( CMAKE_C_COMPILER_ID Clang)
|
|
|
+ set( CMAKE_C_COMPILER_ID Clang )
|
|
|
endif()
|
|
|
set( CMAKE_C_PLATFORM_ID Linux )
|
|
|
if( X86_64 OR MIPS64 OR ARM64_V8A )
|
|
|
@@ -1209,6 +1209,14 @@ set( CMAKE_ASM_COMPILER_FORCED TRUE )
|
|
|
set( CMAKE_COMPILER_IS_GNUASM 1)
|
|
|
set( CMAKE_ASM_SOURCE_FILE_EXTENSIONS s S asm )
|
|
|
|
|
|
+foreach( lang C CXX ASM )
|
|
|
+ if( ANDROID_COMPILER_IS_CLANG )
|
|
|
+ set( CMAKE_${lang}_COMPILER_VERSION ${ANDROID_CLANG_VERSION} )
|
|
|
+ else()
|
|
|
+ set( CMAKE_${lang}_COMPILER_VERSION ${ANDROID_COMPILER_VERSION} )
|
|
|
+ endif()
|
|
|
+endforeach()
|
|
|
+
|
|
|
# flags and definitions
|
|
|
remove_definitions( -DANDROID )
|
|
|
add_definitions( -DANDROID )
|
|
|
@@ -1239,14 +1247,14 @@ endif()
|
|
|
|
|
|
# NDK flags
|
|
|
if (ARM64_V8A )
|
|
|
- set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fpic -ffunction-sections -funwind-tables" )
|
|
|
+ set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -ffunction-sections -funwind-tables" )
|
|
|
set( ANDROID_CXX_FLAGS_RELEASE "-fomit-frame-pointer -fstrict-aliasing" )
|
|
|
set( ANDROID_CXX_FLAGS_DEBUG "-fno-omit-frame-pointer -fno-strict-aliasing" )
|
|
|
if( NOT ANDROID_COMPILER_IS_CLANG )
|
|
|
set( ANDROID_CXX_FLAGS_RELEASE "${ANDROID_CXX_FLAGS_RELEASE} -funswitch-loops -finline-limit=300" )
|
|
|
endif()
|
|
|
elseif( ARMEABI OR ARMEABI_V7A)
|
|
|
- set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fpic -funwind-tables" )
|
|
|
+ set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funwind-tables" )
|
|
|
if( NOT ANDROID_FORCE_ARM_BUILD AND NOT ARMEABI_V6 )
|
|
|
set( ANDROID_CXX_FLAGS_RELEASE "-mthumb -fomit-frame-pointer -fno-strict-aliasing" )
|
|
|
set( ANDROID_CXX_FLAGS_DEBUG "-marm -fno-omit-frame-pointer -fno-strict-aliasing" )
|
|
|
@@ -1265,13 +1273,11 @@ 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" )
|
|
|
- else()
|
|
|
- set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fPIC" )
|
|
|
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 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 "${ANDROID_CXX_FLAGS} -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" )
|
|
|
if( NOT ANDROID_COMPILER_IS_CLANG )
|
|
|
@@ -1470,6 +1476,16 @@ if( MIPS AND BUILD_WITH_ANDROID_NDK AND ANDROID_NDK_RELEASE STREQUAL "r8" )
|
|
|
set( CMAKE_EXE_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK_TOOLCHAINS_PATH}/${ANDROID_GCC_TOOLCHAIN_NAME}/mipself.x ${CMAKE_EXE_LINKER_FLAGS}" )
|
|
|
endif()
|
|
|
|
|
|
+# pie/pic
|
|
|
+if( NOT (ANDROID_NATIVE_API_LEVEL LESS 16) AND (NOT DEFINED ANDROID_APP_PIE OR ANDROID_APP_PIE) AND (CMAKE_VERSION VERSION_GREATER 2.8.8) )
|
|
|
+ set( CMAKE_POSITION_INDEPENDENT_CODE TRUE )
|
|
|
+ set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fPIE -pie")
|
|
|
+else()
|
|
|
+ set( CMAKE_POSITION_INDEPENDENT_CODE FALSE )
|
|
|
+ set( CMAKE_CXX_FLAGS "-fpic ${CMAKE_CXX_FLAGS}" )
|
|
|
+ set( CMAKE_C_FLAGS "-fpic ${CMAKE_C_FLAGS}" )
|
|
|
+endif()
|
|
|
+
|
|
|
# configure rtti
|
|
|
if( DEFINED ANDROID_RTTI AND ANDROID_STL_FORCE_FEATURES )
|
|
|
if( ANDROID_RTTI )
|
|
|
@@ -1662,6 +1678,7 @@ if( NOT PROJECT_NAME STREQUAL "CMAKE_TRY_COMPILE" )
|
|
|
ANDROID_RELRO
|
|
|
ANDROID_LIBM_PATH
|
|
|
ANDROID_EXPLICIT_CRT_LINK
|
|
|
+ ANDROID_APP_PIE
|
|
|
)
|
|
|
if( DEFINED ${__var} )
|
|
|
if( "${__var}" MATCHES " ")
|
|
|
@@ -1746,7 +1763,7 @@ endif()
|
|
|
# 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", "mips", "arm64-v8a", "x86_64", "mips64" depending on ANDROID_ABI
|
|
|
-# ANDROID_NDK_RELEASE : from r5 to r10c; set only for NDK
|
|
|
+# ANDROID_NDK_RELEASE : from r5 to r10d; set only for NDK
|
|
|
# ANDROID_NDK_RELEASE_NUM : numeric ANDROID_NDK_RELEASE version (1000*major+minor)
|
|
|
# ANDROID_ARCH_NAME : "arm", "x86", "mips", "arm64", "x86_64", "mips64" depending on ANDROID_ABI
|
|
|
# ANDROID_SYSROOT : path to the compiler sysroot
|