Added support for the newest NDK version

This commit is contained in:
Alexander Weinrauch 2017-09-19 21:20:07 +02:00 committed by Lukas Dürrenberger
parent 989367e345
commit 0da25a0b87
7 changed files with 56 additions and 70 deletions

View File

@ -143,6 +143,9 @@ if(SFML_OS_ANDROID)
add_definitions("-DSTL_LIBRARY=${ANDROID_STL}") add_definitions("-DSTL_LIBRARY=${ANDROID_STL}")
endif() endif()
# let the user switch ABIs
set(ANDROID_ABI "armeabi-v7a" CACHE STRING "Look at the NDK docs for currently supported ABIs")
# this is a workaround to compile sfml-activity without the stl library as a dependency # this is a workaround to compile sfml-activity without the stl library as a dependency
# we save the original compilation command line to restore it later in Macro.cmake # we save the original compilation command line to restore it later in Macro.cmake
set(CMAKE_CXX_CREATE_SHARED_LIBRARY_WITH_STL ${CMAKE_CXX_CREATE_SHARED_LIBRARY}) set(CMAKE_CXX_CREATE_SHARED_LIBRARY_WITH_STL ${CMAKE_CXX_CREATE_SHARED_LIBRARY})

View File

@ -231,26 +231,50 @@ macro(sfml_add_example target)
endmacro() endmacro()
# macro to find packages on the host OS # macro to find packages on the host OS
# this is the same as in the toolchain file, which is here for Nsight Tegra VS # We do not use the custom toolchain anymore, so we need to define
# since it won't use the Android toolchain file # the macro here
if(CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android") if(SFML_OS_ANDROID)
# macro to find packages on the host OS
macro( find_host_package ) macro( find_host_package )
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER ) set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER ) set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER ) set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER )
if( CMAKE_HOST_WIN32 ) if( CMAKE_HOST_WIN32 )
set(WIN32 1) SET( WIN32 1 )
set(UNIX) SET( UNIX )
elseif( CMAKE_HOST_APPLE ) elseif( CMAKE_HOST_APPLE )
set(APPLE 1) SET( APPLE 1 )
set(UNIX) SET( UNIX )
endif() endif()
find_package( ${ARGN} ) find_package( ${ARGN} )
set(WIN32) SET( WIN32 )
set(APPLE) SET( APPLE )
set(UNIX 1) SET( UNIX 1 )
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
endmacro()
# macro to find programs on the host OS
macro( find_host_program )
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER )
if( CMAKE_HOST_WIN32 )
SET( WIN32 1 )
SET( UNIX )
elseif( CMAKE_HOST_APPLE )
SET( APPLE 1 )
SET( UNIX )
endif()
find_program( ${ARGN} )
SET( WIN32 )
SET( APPLE )
SET( UNIX 1 )
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY ) set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
endmacro() endmacro()
endif() endif()

View File

@ -1555,51 +1555,6 @@ set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
# macro to find packages on the host OS
macro( find_host_package )
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER )
if( CMAKE_HOST_WIN32 )
SET( WIN32 1 )
SET( UNIX )
elseif( CMAKE_HOST_APPLE )
SET( APPLE 1 )
SET( UNIX )
endif()
find_package( ${ARGN} )
SET( WIN32 )
SET( APPLE )
SET( UNIX 1 )
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
endmacro()
# macro to find programs on the host OS
macro( find_host_program )
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER )
if( CMAKE_HOST_WIN32 )
SET( WIN32 1 )
SET( UNIX )
elseif( CMAKE_HOST_APPLE )
SET( APPLE 1 )
SET( UNIX )
endif()
find_program( ${ARGN} )
SET( WIN32 )
SET( APPLE )
SET( UNIX 1 )
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
endmacro()
# export toolchain settings for the try_compile() command # export toolchain settings for the try_compile() command
if( NOT _CMAKE_IN_TRY_COMPILE ) if( NOT _CMAKE_IN_TRY_COMPILE )
set( __toolchain_config "") set( __toolchain_config "")

View File

@ -69,6 +69,9 @@
#include <GLES/glext.h> #include <GLES/glext.h>
// We're not using OpenGL ES 2+ yet, but we can use the sRGB extension // We're not using OpenGL ES 2+ yet, but we can use the sRGB extension
// We need to import gl2platform.h, would normally be included by gl2.h
// which was included by gl2ext.h in older NDK versions
#include <GLES2/gl2platform.h>
#include <GLES2/gl2ext.h> #include <GLES2/gl2ext.h>
#endif #endif

View File

@ -28,6 +28,7 @@
#include <dlfcn.h> #include <dlfcn.h>
#include <errno.h> #include <errno.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <jni.h> #include <jni.h>
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_INFO, "sfml-activity", __VA_ARGS__)) #define LOGE(...) ((void)__android_log_print(ANDROID_LOG_INFO, "sfml-activity", __VA_ARGS__))

View File

@ -43,7 +43,7 @@ std::streambuf::int_type LogcatStream::overflow (std::streambuf::int_type c)
if (c == "\n"[0]) if (c == "\n"[0])
{ {
m_message.push_back(c); m_message.push_back(c);
LOGE(m_message.c_str()); LOGE("%s", m_message.c_str());
m_message.clear(); m_message.clear();
} }

View File

@ -243,10 +243,10 @@ EGLConfig EglContext::getBestConfig(EGLDisplay display, unsigned int bitsPerPixe
{ {
// Set our video settings constraint // Set our video settings constraint
const EGLint attributes[] = { const EGLint attributes[] = {
EGL_BUFFER_SIZE, bitsPerPixel, EGL_BUFFER_SIZE, static_cast<EGLint>(bitsPerPixel),
EGL_DEPTH_SIZE, settings.depthBits, EGL_DEPTH_SIZE, static_cast<EGLint>(settings.depthBits),
EGL_STENCIL_SIZE, settings.stencilBits, EGL_STENCIL_SIZE, static_cast<EGLint>(settings.stencilBits),
EGL_SAMPLE_BUFFERS, settings.antialiasingLevel, EGL_SAMPLE_BUFFERS, static_cast<EGLint>(settings.antialiasingLevel),
EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT, EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT,
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,
EGL_NONE EGL_NONE