Android: Readded support for libc++ and use it as the standard STL

This commit is contained in:
Mario Liebisch 2016-07-23 12:57:36 +02:00
parent 757094a25b
commit 3a2e176e59
3 changed files with 28 additions and 3 deletions

View File

@ -24,7 +24,7 @@ set(ANDROID_NATIVE_API_LEVEL ${ANDROID_API_MIN})
sfml_set_option(ANDROID_NDK "$ENV{ANDROID_NDK}" PATH "Path to the Android NDK") sfml_set_option(ANDROID_NDK "$ENV{ANDROID_NDK}" PATH "Path to the Android NDK")
# define the STL implementation to be used # define the STL implementation to be used
sfml_set_option(ANDROID_STL stlport_shared STRING "Choose the STL implementation to be used (experimental)") sfml_set_option(ANDROID_STL c++_shared STRING "Choose the STL implementation to be used (experimental)")
# default the ABI to ARM v7a for hardware floating point # default the ABI to ARM v7a for hardware floating point
if(NOT ANDROID_ABI) if(NOT ANDROID_ABI)

View File

@ -154,6 +154,8 @@
# Implies -frtti -fno-exceptions. # Implies -frtti -fno-exceptions.
# Available for NDK r7b and newer. # Available for NDK r7b and newer.
# Silently degrades to gnustl_static if not available. # Silently degrades to gnustl_static if not available.
# c++_static -> Use libc++ as a static library.
# c++_shared -> Use libc++ as a shared library.
# #
# ANDROID_STL_FORCE_FEATURES=ON - turn rtti and exceptions support based on # ANDROID_STL_FORCE_FEATURES=ON - turn rtti and exceptions support based on
# chosen runtime. If disabled, then the user is responsible for settings # chosen runtime. If disabled, then the user is responsible for settings
@ -833,7 +835,7 @@ set( ANDROID_STL_FORCE_FEATURES ON CACHE BOOL "automatically configure rtti and
mark_as_advanced( ANDROID_STL ANDROID_STL_FORCE_FEATURES ) mark_as_advanced( ANDROID_STL ANDROID_STL_FORCE_FEATURES )
if( BUILD_WITH_ANDROID_NDK ) if( BUILD_WITH_ANDROID_NDK )
if( NOT "${ANDROID_STL}" MATCHES "^(none|system|system_re|gabi\\+\\+_static|gabi\\+\\+_shared|stlport_static|stlport_shared|gnustl_static|gnustl_shared)$") if( NOT "${ANDROID_STL}" MATCHES "^(none|system|system_re|gabi\\+\\+_static|gabi\\+\\+_shared|stlport_static|stlport_shared|gnustl_static|gnustl_shared|c\\+\\+_static|c\\+\\+_shared)$")
message( FATAL_ERROR "ANDROID_STL is set to invalid value \"${ANDROID_STL}\". message( FATAL_ERROR "ANDROID_STL is set to invalid value \"${ANDROID_STL}\".
The possible values are: The possible values are:
none -> Do not configure the runtime. none -> Do not configure the runtime.
@ -845,6 +847,8 @@ The possible values are:
stlport_shared -> Use the STLport runtime as a shared library. stlport_shared -> Use the STLport runtime as a shared library.
gnustl_static -> (default) Use the GNU STL as a static library. gnustl_static -> (default) Use the GNU STL as a static library.
gnustl_shared -> Use the GNU STL as a shared library. gnustl_shared -> Use the GNU STL as a shared library.
c++_static -> Use libc++ as a static library.
c++_shared -> Use libc++ as a shared library.
" ) " )
endif() endif()
elseif( BUILD_WITH_STANDALONE_TOOLCHAIN ) elseif( BUILD_WITH_STANDALONE_TOOLCHAIN )
@ -1026,6 +1030,27 @@ if( BUILD_WITH_ANDROID_NDK )
else() else()
set( __libstl "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/libstdc++.a" ) set( __libstl "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/libstdc++.a" )
endif() endif()
elseif( ANDROID_STL MATCHES "c\\+\\+_shared" OR ANDROID_STL MATCHES "c\\+\\+_static" )
set( ANDROID_EXCEPTIONS ON )
set( ANDROID_RTTI ON )
set( ANDROID_CXX_ROOT "${ANDROID_NDK}/sources/cxx-stl/" )
set( ANDROID_LLVM_ROOT "${ANDROID_CXX_ROOT}/llvm-libc++" )
if( X86 )
set( ANDROID_ABI_INCLUDE_DIRS "${ANDROID_CXX_ROOT}/gabi++/include" )
else()
set( ANDROID_ABI_INCLUDE_DIRS "${ANDROID_CXX_ROOT}/llvm-libc++abi/include" )
endif()
set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_LLVM_ROOT}/libcxx/include"
"${ANDROID_ABI_INCLUDE_DIRS}" )
# android support sfiles
include_directories ( SYSTEM ${ANDROID_NDK}/sources/android/support/include )
if( ANDROID_STL MATCHES "c\\+\\+_shared" AND EXISTS "${ANDROID_LLVM_ROOT}/libs/${ANDROID_NDK_ABI_NAME}/libc++_shared.so" )
set( __libstl "${ANDROID_LLVM_ROOT}/libs/${ANDROID_NDK_ABI_NAME}/libc++_shared.so" )
elseif( ANDROID_STL MATCHES "c\\+\\+_static" AND EXISTS "${ANDROID_LLVM_ROOT}/libs/${ANDROID_NDK_ABI_NAME}/libc++_static.a" )
set( __libstl "${ANDROID_LLVM_ROOT}/libs/${ANDROID_NDK_ABI_NAME}/libc++_static.a" )
else()
message( "c++ library doesn't exist" )
endif()
else() else()
message( FATAL_ERROR "Unknown runtime: ${ANDROID_STL}" ) message( FATAL_ERROR "Unknown runtime: ${ANDROID_STL}" )
endif() endif()

View File

@ -1,5 +1,5 @@
NDK_TOOLCHAIN_VERSION := 4.9 NDK_TOOLCHAIN_VERSION := 4.9
APP_PLATFORM := android-9 APP_PLATFORM := android-9
APP_STL := stlport_shared APP_STL := c++_shared
APP_ABI := armeabi-v7a APP_ABI := armeabi-v7a
APP_MODULES := sfml-activity sfml-example APP_MODULES := sfml-activity sfml-example