From 3a2e176e5922523c8f931db83d4d99c2fff1e12f Mon Sep 17 00:00:00 2001 From: Mario Liebisch Date: Sat, 23 Jul 2016 12:57:36 +0200 Subject: [PATCH] Android: Readded support for libc++ and use it as the standard STL --- CMakeLists.txt | 2 +- cmake/toolchains/android.toolchain.cmake | 27 +++++++++++++++++++++++- examples/android/jni/Application.mk | 2 +- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fb320b0b..deda6250 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") # 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 if(NOT ANDROID_ABI) diff --git a/cmake/toolchains/android.toolchain.cmake b/cmake/toolchains/android.toolchain.cmake index 5573c79c..d0fdf005 100644 --- a/cmake/toolchains/android.toolchain.cmake +++ b/cmake/toolchains/android.toolchain.cmake @@ -154,6 +154,8 @@ # Implies -frtti -fno-exceptions. # Available for NDK r7b and newer. # 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 # 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 ) 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}\". The possible values are: none -> Do not configure the runtime. @@ -845,6 +847,8 @@ The possible values are: stlport_shared -> Use the STLport runtime as a shared library. gnustl_static -> (default) Use the GNU STL as a static 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() elseif( BUILD_WITH_STANDALONE_TOOLCHAIN ) @@ -1026,6 +1030,27 @@ if( BUILD_WITH_ANDROID_NDK ) else() set( __libstl "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/libstdc++.a" ) 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() message( FATAL_ERROR "Unknown runtime: ${ANDROID_STL}" ) endif() diff --git a/examples/android/jni/Application.mk b/examples/android/jni/Application.mk index 7b0c3855..71828c8d 100644 --- a/examples/android/jni/Application.mk +++ b/examples/android/jni/Application.mk @@ -1,5 +1,5 @@ NDK_TOOLCHAIN_VERSION := 4.9 APP_PLATFORM := android-9 -APP_STL := stlport_shared +APP_STL := c++_shared APP_ABI := armeabi-v7a APP_MODULES := sfml-activity sfml-example