diff --git a/CMakeLists.txt b/CMakeLists.txt index 08c3a4eb4..0c49ed140 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,9 @@ -cmake_minimum_required(VERSION 2.8.3) +# CMake's built-in Android support requires 3.7.0 +if(CMAKE_SYSTEM_NAME MATCHES "Android") + cmake_minimum_required(VERSION 3.7.2) +else() + cmake_minimum_required(VERSION 2.8.3) +endif() # define a macro that helps defining an option macro(sfml_set_option var default type docstring) @@ -38,26 +43,6 @@ if(NOT CMAKE_OSX_SYSROOT) ERROR_QUIET) endif() -# set Android specific options - -# define the minimum API level to be used -sfml_set_option(ANDROID_API_MIN 9 STRING "Choose the Android API level to be used (minimum 9)") -# mirror the setting for the toolchain file -set(ANDROID_NATIVE_API_LEVEL ${ANDROID_API_MIN}) - -# define the 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 -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) - set(ANDROID_ABI armeabi-v7a) -endif() - -#end of Android specific options - # project name project(SFML) @@ -119,12 +104,8 @@ endif() # Android options if(SFML_OS_ANDROID) # make sure there's the android library available - if (${ANDROID_API_MIN} LESS 9) - message(FATAL_ERROR "Android API level must be equal or greater than 9. Please adjust the CMake variable 'ANDROID_API_MIN'.") - endif() - - if(NOT ANDROID_NDK) - message(FATAL_ERROR "The Android NDK couldn't be found. Please adjust the CMake variable 'ANDROID_NDK' to point to the NDK directory.") + if (CMAKE_ANDROID_API LESS 9) + message(FATAL_ERROR "Android API level (${CMAKE_ANDROID_API}) must be equal or greater than 9.") endif() # CMake doesn't support defining the STL to be used with Nsight Tegra, so warn the user @@ -133,14 +114,19 @@ if(SFML_OS_ANDROID) endif() # install everything in $NDK/sources/ because this path is appended by the NDK (convenient) - set(CMAKE_INSTALL_PREFIX ${ANDROID_NDK}/sources/sfml) + set(CMAKE_INSTALL_PREFIX ${CMAKE_ANDROID_NDK}/sources/third_party/sfml) # we install libs in a subdirectory named after the ABI (lib/mips/*.so) - set(LIB_SUFFIX "/${ANDROID_ABI}") + set(LIB_SUFFIX "/${CMAKE_ANDROID_ARCH_ABI}") # pass shared STL configuration (if any) - if (ANDROID_STL MATCHES "_shared") - add_definitions("-DSTL_LIBRARY=${ANDROID_STL}") + if (CMAKE_ANDROID_STL_TYPE MATCHES "_shared") + add_definitions("-DSTL_LIBRARY=${CMAKE_ANDROID_STL_TYPE}") + if(NOT CMAKE_ANDROID_STL_TYPE MATCHES "c\\+\\+_shared") + message("Android: Using ${CMAKE_ANDROID_STL_TYPE} as STL. Set CMAKE_ANDROID_STL_TYPE to c++_shared, if there are any issues.") + endif() + else() + message(WARNING "Android: You're using a static STL (${CMAKE_ANDROID_STL_TYPE}). Set CMAKE_ANDROID_STL_TYPE to c++_shared, if there are any issues.") endif() # let the user switch ABIs @@ -150,12 +136,6 @@ if(SFML_OS_ANDROID) # 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_WITHOUT_STL " -o ") -else() - unset(ANDROID_ABI CACHE) - unset(ANDROID_API_MIN CACHE) - unset(ANDROID_STL CACHE) - unset(ANDROID_NATIVE_API_LEVEL CACHE) - unset(ANDROID_NDK CACHE) endif() # define SFML_STATIC if the build type is not set to 'shared' @@ -525,7 +505,7 @@ elseif(SFML_OS_ANDROID) if(NOT SFML_USE_SYSTEM_DEPS) # install extlibs - install(DIRECTORY extlibs/libs-android/${ANDROID_ABI} DESTINATION extlibs/lib) + install(DIRECTORY extlibs/libs-android/${CMAKE_ANDROID_ARCH_ABI} DESTINATION extlibs/lib) install(FILES extlibs/Android.mk DESTINATION extlibs) endif() diff --git a/cmake/Config.cmake b/cmake/Config.cmake index 594d5e67b..ca841d382 100644 --- a/cmake/Config.cmake +++ b/cmake/Config.cmake @@ -124,5 +124,5 @@ if(SFML_OS_WINDOWS OR SFML_OS_IOS) elseif(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_MACOSX) set(INSTALL_MISC_DIR share/SFML) elseif(SFML_OS_ANDROID) - set(INSTALL_MISC_DIR ${ANDROID_NDK}/sources/sfml) + set(INSTALL_MISC_DIR ${CMAKE_ANDROID_NDK}/sources/third_party/sfml) endif() diff --git a/cmake/Macros.cmake b/cmake/Macros.cmake index 1bcf308ae..2382ea43d 100644 --- a/cmake/Macros.cmake +++ b/cmake/Macros.cmake @@ -229,52 +229,3 @@ macro(sfml_add_example target) endif() endmacro() - -# macro to find packages on the host OS -# We do not use the custom toolchain anymore, so we need to define -# the macro here -if(SFML_OS_ANDROID) - # 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() -endif() - diff --git a/include/SFML/OpenGL.hpp b/include/SFML/OpenGL.hpp index f5105a6c3..1a57e65f0 100644 --- a/include/SFML/OpenGL.hpp +++ b/include/SFML/OpenGL.hpp @@ -69,8 +69,6 @@ #include // 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 #include diff --git a/src/SFML/Audio/CMakeLists.txt b/src/SFML/Audio/CMakeLists.txt index eac6b8c8f..363bf44f0 100644 --- a/src/SFML/Audio/CMakeLists.txt +++ b/src/SFML/Audio/CMakeLists.txt @@ -66,7 +66,7 @@ elseif(SFML_OS_ANDROID) endif() # find external libraries -if(SFML_OS_ANDROID OR SFML_OS_IOS) +if(SFML_OS_IOS) if(NOT SFML_OS_IOS) find_host_package(OpenAL REQUIRED) endif() diff --git a/src/SFML/CMakeLists.txt b/src/SFML/CMakeLists.txt index 61be9ae6a..30f674afd 100644 --- a/src/SFML/CMakeLists.txt +++ b/src/SFML/CMakeLists.txt @@ -36,7 +36,7 @@ elseif(SFML_OS_IOS) set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-ios/") elseif(SFML_OS_ANDROID) set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers") - set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-android/${ANDROID_ABI}") + set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-android/${CMAKE_ANDROID_ARCH_ABI}") endif() # add the SFML sources path diff --git a/src/SFML/Graphics/CMakeLists.txt b/src/SFML/Graphics/CMakeLists.txt index 3ad9b8d42..42d34c9c2 100644 --- a/src/SFML/Graphics/CMakeLists.txt +++ b/src/SFML/Graphics/CMakeLists.txt @@ -116,7 +116,7 @@ if(SFML_OPENGL_ES AND SFML_OS_LINUX) find_package(GLES REQUIRED) include_directories(${EGL_INCLUDE_DIR} ${GLES_INCLUDE_DIR}) endif() -if(SFML_OS_ANDROID OR SFML_OS_IOS) +if(SFML_OS_IOS) find_host_package(Freetype REQUIRED) else() find_package(Freetype REQUIRED) diff --git a/src/SFML/Main/SFMLActivity.cpp b/src/SFML/Main/SFMLActivity.cpp index e55a04928..caf191b28 100644 --- a/src/SFML/Main/SFMLActivity.cpp +++ b/src/SFML/Main/SFMLActivity.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #define LOGE(...) ((void)__android_log_print(ANDROID_LOG_INFO, "sfml-activity", __VA_ARGS__))