mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +08:00
Fixed current Android compilation issues
* Updated the Android toolchain file to support NDKs up to the latest release (r12b; based on https://github.com/gongminmin/android-cmake). * Fixed missing sRGB extension defines - also SFML once again compiles for older target API levels not having the sRGB extensions (fixes #1079, supersedes #1085). * Changed SFML's default STL runtime to `stlport_shared`, since `c++_shared` is no longer supported.
This commit is contained in:
parent
36bb3c4531
commit
757094a25b
@ -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 c++_shared STRING "Choose the STL implementation to be used (experimental)")
|
||||
sfml_set_option(ANDROID_STL stlport_shared STRING "Choose the STL implementation to be used (experimental)")
|
||||
|
||||
# default the ABI to ARM v7a for hardware floating point
|
||||
if(NOT ANDROID_ABI)
|
||||
|
@ -154,8 +154,6 @@
|
||||
# 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
|
||||
@ -600,7 +598,7 @@ if( BUILD_WITH_ANDROID_NDK )
|
||||
endif()
|
||||
if( NOT __availableToolchains )
|
||||
file( GLOB __availableToolchainsLst RELATIVE "${ANDROID_NDK_TOOLCHAINS_PATH}" "${ANDROID_NDK_TOOLCHAINS_PATH}/*" )
|
||||
if( __availableToolchains )
|
||||
if( __availableToolchainsLst )
|
||||
list(SORT __availableToolchainsLst) # we need clang to go after gcc
|
||||
endif()
|
||||
__LIST_FILTER( __availableToolchainsLst "^[.]" )
|
||||
@ -835,7 +833,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|c\\+\\+_static|c\\+\\+_shared)$")
|
||||
if( NOT "${ANDROID_STL}" MATCHES "^(none|system|system_re|gabi\\+\\+_static|gabi\\+\\+_shared|stlport_static|stlport_shared|gnustl_static|gnustl_shared)$")
|
||||
message( FATAL_ERROR "ANDROID_STL is set to invalid value \"${ANDROID_STL}\".
|
||||
The possible values are:
|
||||
none -> Do not configure the runtime.
|
||||
@ -847,8 +845,6 @@ 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 )
|
||||
@ -973,6 +969,7 @@ if( NOT EXISTS "${ANDROID_CLANG_TOOLCHAIN_ROOT}/bin/${_clang_name}${TOOL_OS_SUFF
|
||||
set( _clang_name "clang" )
|
||||
endif()
|
||||
|
||||
|
||||
# setup paths and STL for NDK
|
||||
if( BUILD_WITH_ANDROID_NDK )
|
||||
set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_NDK_TOOLCHAINS_PATH}/${ANDROID_GCC_TOOLCHAIN_NAME}${ANDROID_NDK_TOOLCHAINS_SUBPATH}" )
|
||||
@ -990,7 +987,7 @@ if( BUILD_WITH_ANDROID_NDK )
|
||||
set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_NDK}/sources/cxx-stl/system/include" )
|
||||
elseif( ANDROID_STL MATCHES "gabi" )
|
||||
if( ANDROID_NDK_RELEASE_NUM LESS 7000 ) # before r7
|
||||
message( FATAL_ERROR "gabi++ is not awailable in your NDK. You have to upgrade to NDK r7 or newer to use gabi++.")
|
||||
message( FATAL_ERROR "gabi++ is not available in your NDK. You have to upgrade to NDK r7 or newer to use gabi++.")
|
||||
endif()
|
||||
set( ANDROID_RTTI ON )
|
||||
set( ANDROID_EXCEPTIONS OFF )
|
||||
@ -1029,27 +1026,6 @@ 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()
|
||||
@ -1122,7 +1098,12 @@ if( NOT CMAKE_C_COMPILER )
|
||||
endif()
|
||||
set( CMAKE_ASM_COMPILER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc${TOOL_OS_SUFFIX}" CACHE PATH "assembler" )
|
||||
set( CMAKE_STRIP "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-strip${TOOL_OS_SUFFIX}" CACHE PATH "strip" )
|
||||
if( EXISTS "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc-ar${TOOL_OS_SUFFIX}" )
|
||||
# Use gcc-ar if we have it for better LTO support.
|
||||
set( CMAKE_AR "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc-ar${TOOL_OS_SUFFIX}" CACHE PATH "archive" )
|
||||
else()
|
||||
set( CMAKE_AR "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-ar${TOOL_OS_SUFFIX}" CACHE PATH "archive" )
|
||||
endif()
|
||||
set( CMAKE_LINKER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-ld${TOOL_OS_SUFFIX}" CACHE PATH "linker" )
|
||||
set( CMAKE_NM "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-nm${TOOL_OS_SUFFIX}" CACHE PATH "nm" )
|
||||
set( CMAKE_OBJCOPY "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-objcopy${TOOL_OS_SUFFIX}" CACHE PATH "objcopy" )
|
||||
|
@ -1,5 +1,5 @@
|
||||
NDK_TOOLCHAIN_VERSION := 4.8
|
||||
NDK_TOOLCHAIN_VERSION := 4.9
|
||||
APP_PLATFORM := android-9
|
||||
APP_STL := c++_shared
|
||||
APP_STL := stlport_shared
|
||||
APP_ABI := armeabi-v7a
|
||||
APP_MODULES := sfml-activity sfml-example
|
||||
|
@ -68,6 +68,9 @@
|
||||
#include <GLES/gl.h>
|
||||
#include <GLES/glext.h>
|
||||
|
||||
// We're not using OpenGL ES 2+ yet, but we can use the sRGB extension
|
||||
#include <GLES2/gl2ext.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -112,8 +112,13 @@
|
||||
#define GLEXT_GL_INVALID_FRAMEBUFFER_OPERATION GL_INVALID_FRAMEBUFFER_OPERATION_OES
|
||||
|
||||
// Core since 3.0 - EXT_sRGB
|
||||
#ifdef GL_EXT_sRGB
|
||||
#define GLEXT_texture_sRGB GL_EXT_sRGB
|
||||
#define GLEXT_GL_SRGB8_ALPHA8 GL_SRGB8_ALPHA8_EXT
|
||||
#else
|
||||
#define GLEXT_texture_sRGB false
|
||||
#define GLEXT_GL_SRGB8_ALPHA8 0
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user