From 60894d1c1a5e51c6a02f85edbedf8ec91db1006b Mon Sep 17 00:00:00 2001 From: Jonathan De Wachter Date: Sun, 22 Sep 2013 17:16:48 +0200 Subject: [PATCH] [Android] Rewrote CMake scripts to compile SFML with our new toolchain --- CMakeLists.txt | 38 +++++- cmake/Config.cmake | 23 +++- cmake/Macros.cmake | 127 ++++++------------ src/SFML/Android.mk | 35 ++--- src/SFML/Audio/ALCheck.hpp | 9 +- src/SFML/Audio/Android.mk | 20 --- src/SFML/Audio/CMakeLists.txt | 31 ++++- src/SFML/Audio/SoundFile.cpp | 10 +- src/SFML/CMakeLists.txt | 15 ++- src/SFML/Graphics/Android.mk | 38 ------ src/SFML/Graphics/CMakeLists.txt | 8 +- src/SFML/Graphics/Font.cpp | 10 +- src/SFML/Graphics/Image.cpp | 6 +- src/SFML/Main/Android.mk | 7 - src/SFML/Main/CMakeLists.txt | 25 ++-- src/SFML/Main/MainAndroid.cpp | 21 +-- src/SFML/Network/Android.mk | 17 --- src/SFML/System/Android.mk | 21 --- src/SFML/System/CMakeLists.txt | 9 +- src/SFML/Window/Android.mk | 23 ---- src/SFML/Window/Android/Activity.cpp | 41 ++++++ .../SFML/Window/Android/Activity.hpp | 9 +- src/SFML/Window/Android/EglContext.cpp | 6 +- src/SFML/Window/Android/InputImpl.cpp | 4 +- src/SFML/Window/Android/VideoModeImpl.cpp | 5 +- src/SFML/Window/Android/WindowImplAndroid.cpp | 6 +- src/SFML/Window/CMakeLists.txt | 22 +-- src/SFML/Window/Window.cpp | 1 + 28 files changed, 260 insertions(+), 327 deletions(-) delete mode 100644 src/SFML/Audio/Android.mk delete mode 100644 src/SFML/Graphics/Android.mk delete mode 100644 src/SFML/Main/Android.mk delete mode 100644 src/SFML/Network/Android.mk delete mode 100644 src/SFML/System/Android.mk delete mode 100644 src/SFML/Window/Android.mk create mode 100644 src/SFML/Window/Android/Activity.cpp rename include/SFML/Main/activity.hpp => src/SFML/Window/Android/Activity.hpp (94%) diff --git a/CMakeLists.txt b/CMakeLists.txt index c01828563..ee99975c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,14 +28,18 @@ set(VERSION_PATCH 0) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) # add an option for choosing the build type (shared or static) -if(NOT IOS) +if(NOT (IOS OR ANDROID)) sfml_set_option(BUILD_SHARED_LIBS TRUE BOOL "TRUE to build SFML as shared libraries, FALSE to build it as static libraries") else() - set(BUILD_SHARED_LIBS FALSE) + if(IOS) + set(BUILD_SHARED_LIBS FALSE) + elseif(ANDROID) + set(BUILD_SHARED_LIBS TRUE) + endif() endif() # add an option for building the examples -if(NOT IOS) +if(NOT (IOS OR ANDROID)) sfml_set_option(SFML_BUILD_EXAMPLES FALSE BOOL "TRUE to build the SFML examples, FALSE to ignore them") else() set(SFML_BUILD_EXAMPLES FALSE) @@ -65,6 +69,27 @@ if(SFML_OS_MACOSX) sfml_set_option(SFML_INSTALL_XCODE4_TEMPLATES FALSE BOOL "TRUE to automatically install the Xcode 4 templates, FALSE to do nothing about it") endif() +# Android options +if(ANDROID) + # force usage of the STL port + set(ANDROID_USE_STLPORT TRUE) + + # make sure there's an EGL implementation available + if (${ANDROID_ABI} MATCHES "armeabi" AND ${ANDROID_NATIVE_API_LEVEL} LESS 3) + message(FATAL_ERROR "API level must be equal or greater than 3 for ARM arches") + endif() + + if ((${ANDROID_ABI} MATCHES "x86" OR ${ANDROID_ABI} MATCHES "mips") AND ${ANDROID_NATIVE_API_LEVEL} LESS 9) + message(FATAL_ERROR "API level must be equal or greater than 9 for x86 and MIPS arches") + endif() + + # install everything in $NDK/sources/ because this path is appended by the NDK (convenient) + set(CMAKE_INSTALL_PREFIX ${ANDROID_NDK}/sources/sfml) + + # we install libs in a subdirectory named after the ABI (lib/mips/*.so) + set(LIB_SUFFIX "/${ANDROID_ABI}") +endif() + # define SFML_STATIC if the build type is not set to 'shared' if(NOT BUILD_SHARED_LIBS) add_definitions(-DSFML_STATIC) @@ -222,7 +247,9 @@ endif() install(FILES license.txt DESTINATION ${INSTALL_MISC_DIR}) install(FILES readme.txt DESTINATION ${INSTALL_MISC_DIR}) -install(FILES cmake/Modules/FindSFML.cmake DESTINATION ${INSTALL_MISC_DIR}/cmake/Modules) +if(NOT SFML_OS_ANDROID) + install(FILES cmake/Modules/FindSFML.cmake DESTINATION ${INSTALL_MISC_DIR}/cmake/Modules) +endif() # install 3rd-party libraries and tools if(SFML_OS_WINDOWS) @@ -274,7 +301,8 @@ elseif(SFML_OS_IOS) elseif(SFML_OS_ANDROID) - install(DIRECTORY extlibs/android/extlibs DESTINATION .) + install(DIRECTORY extlibs/android/extlibs/lib/${ANDROID_ABI} DESTINATION extlibs/lib) + install(FILES extlibs/android/extlibs/Android.mk DESTINATION extlibs) install(FILES src/SFML/Android.mk DESTINATION .) endif() diff --git a/cmake/Config.cmake b/cmake/Config.cmake index e5ea07f27..58c30cb76 100644 --- a/cmake/Config.cmake +++ b/cmake/Config.cmake @@ -12,9 +12,16 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") else() message(FATAL_ERROR "Unsupported architecture") return() - endif() + endif() elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - set(SFML_OS_LINUX 1) + set(SFML_OS_UNIX 1) + if(ANDROID) + # use the OpenGL ES implementation on Android + set(OPENGL_ES 1) + set(SFML_OS_ANDROID 1) + else() + set(SFML_OS_LINUX 1) + endif() elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") set(SFML_OS_FREEBSD 1) elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") @@ -39,14 +46,14 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") STRING(REGEX REPLACE "10\\.([0-9]).*" "\\1" MACOSX_VERSION "${MACOSX_VERSION_RAW}") if(${MACOSX_VERSION} LESS 7) message(FATAL_ERROR "Unsupported version of OS X: ${MACOSX_VERSION_RAW}") - return() + return() endif() endif() elseif(${CMAKE_SYSTEM_NAME} MATCHES "Android") set(SFML_OS_ANDROID 1) # use the OpenGL ES implementation on Android - set(OPENGL_ES 1) + set(OPENGL_ES 1) else() message(FATAL_ERROR "Unsupported operating system") return() @@ -89,10 +96,12 @@ else() message(FATAL_ERROR "Unsupported compiler") return() endif() - -# define the install directory for miscellaneous files -if(SFML_OS_WINDOWS OR SFML_OS_ANDROID) + +# define the install directory for miscellaneous files +if(SFML_OS_WINDOWS) set(INSTALL_MISC_DIR .) 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) endif() diff --git a/cmake/Macros.cmake b/cmake/Macros.cmake index 46a765341..7c3db2f42 100644 --- a/cmake/Macros.cmake +++ b/cmake/Macros.cmake @@ -9,9 +9,7 @@ macro(sfml_add_library target) # parse the arguments cmake_parse_arguments(THIS "" "" "SOURCES;DEPENDS;EXTERNAL_LIBS" ${ARGN}) - -if(NOT ANDROID) - + # create the target add_library(${target} ${THIS_SOURCES}) @@ -42,8 +40,11 @@ if(NOT ANDROID) endif() # set the version and soversion of the target (for compatible systems -- mostly Linuxes) - set_target_properties(${target} PROPERTIES SOVERSION ${VERSION_MAJOR}) - set_target_properties(${target} PROPERTIES VERSION ${VERSION_MAJOR}.${VERSION_MINOR}) + # except for Android which strips soversion suffixes + if(NOT ANDROID) + set_target_properties(${target} PROPERTIES SOVERSION ${VERSION_MAJOR}) + set_target_properties(${target} PROPERTIES VERSION ${VERSION_MAJOR}.${VERSION_MINOR}) + endif() # set the target's folder (for IDEs that support it, e.g. Visual Studio) set_target_properties(${target} PROPERTIES FOLDER "SFML") @@ -107,96 +108,54 @@ if(NOT ANDROID) LIBRARY DESTINATION lib${LIB_SUFFIX} COMPONENT bin ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT devel FRAMEWORK DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX} COMPONENT bin) +endmacro() -else() +# add a new target which is a SFML example +# ex: sfml_add_example(ftp +# SOURCES ftp.cpp ... +# DEPENDS sfml-network sfml-system) +macro(sfml_add_example target) - # create an empty target added to the default build - add_custom_target(${target} ALL) + # parse the arguments + sfml_parse_arguments(THIS "SOURCES;DEPENDS" "GUI_APP" ${ARGN}) - # get the module name (extract 'network' from 'sfml-network' for example) - string(SUBSTRING ${target} 5 -1 MODULE_NAME) + # set a source group for the source files + source_group("" FILES ${THIS_SOURCES}) - # make the first letter a capital letter ('network' -> 'Network')s - string(SUBSTRING ${MODULE_NAME} 0 1 FIRST_LETTER) - string(TOUPPER ${FIRST_LETTER} FIRST_LETTER) - string(REGEX REPLACE "^.(.*)" "${FIRST_LETTER}\\1" PROTO_NAME_CAP "${MODULE_NAME}") - set(MODULE_NAME ${PROTO_NAME_CAP}) - - # create an empty Application.mk ready to be filled - set(APPLICATION_MK ${CMAKE_BINARY_DIR}/src/SFML/${MODULE_NAME}/Application.mk) - file(WRITE ${APPLICATION_MK}) - - # define several path for later use - set(INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include) - set(SRC_DIR ${PROJECT_SOURCE_DIR}/src) - set(EXTLIBS_DIR ${PROJECT_SOURCE_DIR}/extlibs/android/extlibs) - - # add support for Windows under Cygwin (add C:/cygwin64 to path) - execute_process(COMMAND uname -o OUTPUT_VARIABLE UNAME_RESULT) - if (UNAME_RESULT MATCHES Cygwin) - execute_process(COMMAND cygpath --mixed / OUTPUT_VARIABLE CYGPATH) - string(STRIP ${CYGPATH} CYGPATH) - - set(INCLUDE_DIR ${CYGPATH}${PROJECT_SOURCE_DIR}/include) - set(SRC_DIR ${CYGPATH}${PROJECT_SOURCE_DIR}/src) - set(EXTLIBS_DIR ${CYGPATH}${PROJECT_SOURCE_DIR}/extlibs/android/extlibs) - endif() - - # write the Application.mk - file(APPEND ${APPLICATION_MK} "NDK_APP_OUT := ${CMAKE_BINARY_DIR}/src/SFML/${MODULE_NAME}/obj\n") - file(APPEND ${APPLICATION_MK} "APP_PLATFORM := android-${ANDROID_API_LEVEL}\n") - file(APPEND ${APPLICATION_MK} "APP_STL := stlport_static\n") - file(APPEND ${APPLICATION_MK} "APP_BUILD_SCRIPT := Android.mk\n") - file(APPEND ${APPLICATION_MK} "APP_MODULES := ${target}\n") - file(APPEND ${APPLICATION_MK} "APP_CPPFLAGS += -I${INCLUDE_DIR}\n") - file(APPEND ${APPLICATION_MK} "APP_CPPFLAGS += -I${SRC_DIR}\n") - file(APPEND ${APPLICATION_MK} "APP_CPPFLAGS += -I${EXTLIBS_DIR}/include\n") - file(APPEND ${APPLICATION_MK} "APP_CPPFLAGS += -DSFML_OPENGL_ES\n") - - if (ANDROID_ABI_ARM) - file(APPEND ${APPLICATION_MK} "APP_ABI += armeabi\n") + # create the target + if(THIS_GUI_APP AND WINDOWS) + add_executable(${target} WIN32 ${THIS_SOURCES}) + target_link_libraries(${target} sfml-main) + else() + add_executable(${target} ${THIS_SOURCES}) endif() - if (ANDROID_ABI_ARMv7) - file(APPEND ${APPLICATION_MK} "APP_ABI += armeabi-v7a\n") + # set the debug suffix + set_target_properties(${target} PROPERTIES DEBUG_POSTFIX -d) + + # set the target's folder (for IDEs that support it, e.g. Visual Studio) + set_target_properties(${target} PROPERTIES FOLDER "Examples") + + # for gcc >= 4.0 on Windows, apply the SFML_USE_STATIC_STD_LIBS option if it is enabled + if(WINDOWS AND COMPILER_GCC AND SFML_USE_STATIC_STD_LIBS) + if(NOT GCC_VERSION VERSION_LESS "4") + set_target_properties(${target} PROPERTIES LINK_FLAGS "-static-libgcc -static-libstdc++") + endif() endif() - if (ANDROID_ABI_MIPS) - file(APPEND ${APPLICATION_MK} "APP_ABI += mips\n") + # link the target to its SFML dependencies + if(THIS_DEPENDS) + target_link_libraries(${target} ${THIS_DEPENDS}) endif() - if (ANDROID_ABI_x86) - file(APPEND ${APPLICATION_MK} "APP_ABI += x86\n") - endif() + # add the install rule + install(TARGETS ${target} + RUNTIME DESTINATION ${INSTALL_MISC_DIR}/examples/${target} COMPONENT examples) - # define the target build rules - set(DIR ${PROJECT_SOURCE_DIR}/src/SFML/${MODULE_NAME}) - set(NDK_MODULE_PATH ${PROJECT_SOURCE_DIR}/extlibs/android) - set(NDK_PROJECT_PATH ${PROJECT_SOURCE_DIR}/src/SFML/${MODULE_NAME}) - set(NDK_BUILD ${ANDROID_NDK_PATH}/ndk-build) - set(NDK_APPLICATION_MK NDK_APPLICATION_MK=${APPLICATION_MK}) - - # create the environment for ndk-build - set(NDK_ENVIRONMENT NDK_MODULE_PATH=${NDK_MODULE_PATH} NDK_PROJECT_PATH=${NDK_PROJECT_PATH}) - - # invoke the ndk-build scripts from the ndk with the right parameters - add_custom_command(TARGET ${target} POST_BUILD COMMAND ${NDK_BUILD} -C ${DIR} ${NDK_APPLICATION_MK} ${NDK_ENVIRONMENT}) - - # define the target install rules - if (ANDROID_ABI_ARM) - install(DIRECTORY ${CMAKE_BINARY_DIR}/src/SFML/${MODULE_NAME}/obj/local/armeabi DESTINATION ${ANDROID_NDK_PATH}/sources/sfml/lib/ PATTERN "objs" EXCLUDE) - endif() - if (ANDROID_ABI_ARMv7) - install(DIRECTORY ${CMAKE_BINARY_DIR}/src/SFML/${MODULE_NAME}/obj/local/armeabi-v7a DESTINATION ${ANDROID_NDK_PATH}/sources/sfml/lib PATTERN "objs" EXCLUDE) - endif() - if (ANDROID_ABI_MIPS) - install(DIRECTORY ${CMAKE_BINARY_DIR}/src/SFML/${MODULE_NAME}/obj/local/mips DESTINATION ${ANDROID_NDK_PATH}/sources/sfml/lib PATTERN "objs" EXCLUDE) - endif() - if (ANDROID_ABI_x86) - install(DIRECTORY ${CMAKE_BINARY_DIR}/src/SFML/${MODULE_NAME}/obj/local/x86 DESTINATION ${ANDROID_NDK_PATH}/sources/sfml/lib PATTERN "objs" EXCLUDE) - endif() - -endif() + # install the example's source code + install(FILES ${THIS_SOURCES} + DESTINATION ${INSTALL_MISC_DIR}/examples/${target} + COMPONENT examples) endmacro() diff --git a/src/SFML/Android.mk b/src/SFML/Android.mk index 3dfe4750e..a55837468 100644 --- a/src/SFML/Android.mk +++ b/src/SFML/Android.mk @@ -2,51 +2,56 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := sfml-system -LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libsfml-system.a +LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libsfml-system.so LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include +LOCAL_EXPORT_LDLIBS := -llog -landroid -include $(PREBUILT_STATIC_LIBRARY) +include $(PREBUILT_SHARED_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE := sfml-window -LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libsfml-window.a +LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libsfml-window.so LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include LOCAL_EXPORT_LDLIBS := -lEGL +LOCAL_SHARED_LIBRARIES := sfml-system -include $(PREBUILT_STATIC_LIBRARY) +include $(PREBUILT_SHARED_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE := sfml-graphics -LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libsfml-graphics.a +LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libsfml-graphics.so LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include -LOCAL_EXPORT_LDLIBS := -lGLESv1_CM +#LOCAL_EXPORT_LDLIBS := -lGLESv1_CM LOCAL_EXPORT_C_INCLUDES += $(LOCAL_PATH)/extlibs/include -LOCAL_STATIC_LIBRARIES := jpeg freetype +LOCAL_SHARED_LIBRARIES := freetype jpeg +LOCAL_SHARED_LIBRARIES += sfml-system sfml-window -include $(PREBUILT_STATIC_LIBRARY) +include $(PREBUILT_SHARED_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE := sfml-audio -LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libsfml-audio.a +LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libsfml-audio.so LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include +#LOCAL_EXPORT_LDLIBS := -lOpenSLES +LOCAL_SHARED_LIBRARIES := openal sndfile +LOCAL_SHARED_LIBRARIES += sfml-system sfml-window -LOCAL_EXPORT_C_INCLUDES += $(LOCAL_PATH)/extlibs/include -LOCAL_WHOLE_STATIC_LIBRARIES := ogg vorbis vorbisenc flac sndfile openal - -include $(PREBUILT_STATIC_LIBRARY) +include $(PREBUILT_SHARED_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE := sfml-network -LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libsfml-network.a +LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libsfml-network.so LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include +LOCAL_SHARED_LIBRARIES := sfml-system -include $(PREBUILT_STATIC_LIBRARY) +include $(PREBUILT_SHARED_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE := sfml-main LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libsfml-main.a LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include +LOCAL_SHARED_LIBRARIES := sfml-system sfml-window include $(PREBUILT_STATIC_LIBRARY) diff --git a/src/SFML/Audio/ALCheck.hpp b/src/SFML/Audio/ALCheck.hpp index 2384c8b18..f119c15bf 100644 --- a/src/SFML/Audio/ALCheck.hpp +++ b/src/SFML/Audio/ALCheck.hpp @@ -31,13 +31,8 @@ #include #include #include -#ifndef SFML_SYSTEM_ANDROID - #include - #include -#else - #include - #include -#endif +#include +#include namespace sf diff --git a/src/SFML/Audio/Android.mk b/src/SFML/Audio/Android.mk deleted file mode 100644 index b486c9688..000000000 --- a/src/SFML/Audio/Android.mk +++ /dev/null @@ -1,20 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE := sfml-audio - -LOCAL_SRC_FILES := ALCheck.cpp -LOCAL_SRC_FILES += AudioDevice.cpp -LOCAL_SRC_FILES += Listener.cpp -LOCAL_SRC_FILES += Music.cpp -LOCAL_SRC_FILES += Sound.cpp -LOCAL_SRC_FILES += SoundBuffer.cpp -LOCAL_SRC_FILES += SoundBufferRecorder.cpp -LOCAL_SRC_FILES += SoundFile.cpp -LOCAL_SRC_FILES += SoundRecorder.cpp -LOCAL_SRC_FILES += SoundSource.cpp -LOCAL_SRC_FILES += SoundStream.cpp - -include $(BUILD_STATIC_LIBRARY) - -$(call import-module,extlibs) diff --git a/src/SFML/Audio/CMakeLists.txt b/src/SFML/Audio/CMakeLists.txt index 8e37b0b56..d952af2b9 100644 --- a/src/SFML/Audio/CMakeLists.txt +++ b/src/SFML/Audio/CMakeLists.txt @@ -29,7 +29,7 @@ set(SRC ${INCROOT}/SoundStream.hpp ) source_group("" FILES ${SRC}) -if(NOT ANDROID) + # let CMake know about our additional audio libraries paths (on Windows and OSX) if(SFML_OS_WINDOWS) set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers/AL") @@ -40,14 +40,37 @@ elseif(SFML_OS_MACOSX) endif() # find external libraries -find_package(OpenAL REQUIRED) -find_package(Sndfile REQUIRED) +if(NOT ANDROID) + find_package(OpenAL REQUIRED) + find_package(Sndfile REQUIRED) + set(AUDIO_EXT_LIBS ${OPENAL_LIBRARY} ${SNDFILE_LIBRARY}) +else() + set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/android/extlibs/include/AL") + find_host_package(OpenAL REQUIRED) + find_host_package(Sndfile REQUIRED) + set(AUDIO_EXT_INCLUDE_PATHS ${OPENAL_INCLUDE_DIRS} ${SNDFILE_INCLUDE_DIR}) + set(AUDIO_EXT_LIBS -landroid + -lOpenSLES + ${OPENAL_LIBRARY} + ${SNDFILE_LIBRARY} + ${PROJECT_SOURCE_DIR}/extlibs/android/extlibs/lib/${ANDROID_ABI}/libvorbisenc.so + ${PROJECT_SOURCE_DIR}/extlibs/android/extlibs/lib/${ANDROID_ABI}/libvorbis.so + ${PROJECT_SOURCE_DIR}/extlibs/android/extlibs/lib/${ANDROID_ABI}/libFLAC.so + ${PROJECT_SOURCE_DIR}/extlibs/android/extlibs/lib/${ANDROID_ABI}/libogg.so) +endif() # add include paths of external libraries include_directories(${OPENAL_INCLUDE_DIR} ${SNDFILE_INCLUDE_DIR}) -endif() + # define the sfml-audio target +if(NOT ANDROID) sfml_add_library(sfml-audio SOURCES ${SRC} DEPENDS sfml-system EXTERNAL_LIBS ${OPENAL_LIBRARY} ${SNDFILE_LIBRARY}) +else() +sfml_add_library(sfml-audio + SOURCES ${SRC} + DEPENDS sfml-system sfml-window + EXTERNAL_LIBS ${AUDIO_EXT_LIBS}) +endif() diff --git a/src/SFML/Audio/SoundFile.cpp b/src/SFML/Audio/SoundFile.cpp index 43f089a7c..59d3037d1 100644 --- a/src/SFML/Audio/SoundFile.cpp +++ b/src/SFML/Audio/SoundFile.cpp @@ -26,12 +26,12 @@ // Headers //////////////////////////////////////////////////////////// #include +#ifdef SFML_SYSTEM_ANDROID + #include + #include +#endif #include #include -#ifdef SFML_SYSTEM_ANDROID - #include - #include -#endif #include #include @@ -118,7 +118,7 @@ bool SoundFile::openRead(const std::string& filename) #else - priv::ActivityStates* states = priv::getActivityStates(NULL); + priv::ActivityStates* states = priv::getActivity(NULL); Lock lock(states->mutex); // Open the file diff --git a/src/SFML/CMakeLists.txt b/src/SFML/CMakeLists.txt index 0f76a3d1f..35da00de7 100644 --- a/src/SFML/CMakeLists.txt +++ b/src/SFML/CMakeLists.txt @@ -26,6 +26,9 @@ elseif(SFML_OS_MACOSX) elseif(IOS) set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers") set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-ios/") +elseif(ANDROID) + set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/android/extlibs/include") + set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/android/extlibs/lib/${ANDROID_ABI}") endif() # add the SFML sources path @@ -40,9 +43,11 @@ set(LIBRARY_OUTPUT_PATH "${PROJECT_BINARY_DIR}/lib") # add the modules subdirectories add_subdirectory(System) add_subdirectory(Window) -add_subdirectory(Network) -add_subdirectory(Graphics) -if(NOT SFML_OS_IOS) - add_subdirectory(Audio) +if(SFML_OS_WINDOWS OR SFML_OS_ANDROID OR SFML_OS_IOS) + add_subdirectory(Main) endif() -add_subdirectory(Main) +add_subdirectory(Network) +add_subdirectory(Graphics) +if(NOT SFML_OS_IOS OR NOT (SFML_OS_ANDROID AND ${ANDROID_ABI} MATCHES "mips")) + add_subdirectory(Audio) +endif() diff --git a/src/SFML/Graphics/Android.mk b/src/SFML/Graphics/Android.mk deleted file mode 100644 index 3320a5691..000000000 --- a/src/SFML/Graphics/Android.mk +++ /dev/null @@ -1,38 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE := sfml-graphics - -LOCAL_SRC_FILES := Color.cpp -LOCAL_SRC_FILES += GLCheck.cpp -LOCAL_SRC_FILES += GLExtensions.cpp -LOCAL_SRC_FILES += Image.cpp -LOCAL_SRC_FILES += ImageLoader.cpp -LOCAL_SRC_FILES += RenderStates.cpp -LOCAL_SRC_FILES += RenderTexture.cpp -LOCAL_SRC_FILES += RenderTarget.cpp -LOCAL_SRC_FILES += RenderWindow.cpp -LOCAL_SRC_FILES += Shader.cpp -LOCAL_SRC_FILES += Texture.cpp -LOCAL_SRC_FILES += TextureSaver.cpp -LOCAL_SRC_FILES += Transform.cpp -LOCAL_SRC_FILES += Transformable.cpp -LOCAL_SRC_FILES += View.cpp -LOCAL_SRC_FILES += Vertex.cpp -LOCAL_SRC_FILES += Shape.cpp -LOCAL_SRC_FILES += CircleShape.cpp -LOCAL_SRC_FILES += RectangleShape.cpp -LOCAL_SRC_FILES += ConvexShape.cpp -LOCAL_SRC_FILES += Sprite.cpp -LOCAL_SRC_FILES += Font.cpp -LOCAL_SRC_FILES += Text.cpp -LOCAL_SRC_FILES += VertexArray.cpp -LOCAL_SRC_FILES += RenderTextureImpl.cpp -LOCAL_SRC_FILES += RenderTextureImplFBO.cpp -LOCAL_SRC_FILES += RenderTextureImplDefault.cpp - -LOCAL_CPPFLAGS := -DGL_GLEXT_PROTOTYPES -DSFML_OPENGL_ES - -include $(BUILD_STATIC_LIBRARY) - -$(call import-module,extlibs) diff --git a/src/SFML/Graphics/CMakeLists.txt b/src/SFML/Graphics/CMakeLists.txt index ac4ffa88c..72cd69a13 100644 --- a/src/SFML/Graphics/CMakeLists.txt +++ b/src/SFML/Graphics/CMakeLists.txt @@ -127,7 +127,13 @@ if(IOS) find_package(JPEG REQUIRED) find_package(Freetype REQUIRED) set(GRAPHICS_EXT_INCLUDE_PATHS ${FREETYPE_INCLUDE_DIRS} ${JPEG_INCLUDE_DIR}) - set(GRAPHICS_EXT_LIBS "-framework OpenGLES ${FREETYPE_LIBRARY} ${JPEG_LIBRARY}") + set(GRAPHICS_EXT_LIBS "-framework OpenGLES ${FREETYPE_LIBRARY} ${JPEG_LIBRARY}") +elseif(ANDROID) + find_host_package(JPEG REQUIRED) + find_host_package(Freetype REQUIRED) + set(GRAPHICS_EXT_INCLUDE_PATHS ${FREETYPE_INCLUDE_DIRS} ${JPEG_INCLUDE_DIR}) + set(GRAPHICS_EXT_LIBS -lz ${FREETYPE_LIBRARY} ${JPEG_LIBRARY}) + add_definitions(-DGL_GLEXT_PROTOTYPES) endif() # add include paths of external libraries diff --git a/src/SFML/Graphics/Font.cpp b/src/SFML/Graphics/Font.cpp index 727a5c119..3fe4537a2 100644 --- a/src/SFML/Graphics/Font.cpp +++ b/src/SFML/Graphics/Font.cpp @@ -27,12 +27,12 @@ //////////////////////////////////////////////////////////// #include #include +#ifdef SFML_SYSTEM_ANDROID + #include + #include +#endif #include #include -#ifdef SFML_SYSTEM_ANDROID - #include - #include -#endif #include #include FT_FREETYPE_H #include FT_GLYPH_H @@ -149,7 +149,7 @@ bool Font::loadFromFile(const std::string& filename) #else - priv::ActivityStates* states = priv::getActivityStates(NULL); + priv::ActivityStates* states = priv::getActivity(NULL); Lock lock(states->mutex); // Open the file diff --git a/src/SFML/Graphics/Image.cpp b/src/SFML/Graphics/Image.cpp index 2dd84e894..1441e920a 100644 --- a/src/SFML/Graphics/Image.cpp +++ b/src/SFML/Graphics/Image.cpp @@ -27,11 +27,11 @@ //////////////////////////////////////////////////////////// #include #include -#include #ifdef SFML_SYSTEM_ANDROID + #include #include - #include #endif +#include #include #include @@ -112,7 +112,7 @@ bool Image::loadFromFile(const std::string& filename) #else - priv::ActivityStates* states = priv::getActivityStates(NULL); + priv::ActivityStates* states = priv::getActivity(NULL); Lock lock(states->mutex); // Open the file diff --git a/src/SFML/Main/Android.mk b/src/SFML/Main/Android.mk deleted file mode 100644 index 481b202bf..000000000 --- a/src/SFML/Main/Android.mk +++ /dev/null @@ -1,7 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE := sfml-main -LOCAL_SRC_FILES := SFML_Main.cpp - -include $(BUILD_STATIC_LIBRARY) diff --git a/src/SFML/Main/CMakeLists.txt b/src/SFML/Main/CMakeLists.txt index 6bbbc2667..d4561de65 100644 --- a/src/SFML/Main/CMakeLists.txt +++ b/src/SFML/Main/CMakeLists.txt @@ -14,22 +14,17 @@ else() endif() source_group("" FILES ${SRC}) -if(NOT ANDROID) - # define the sfml-main target - add_library(sfml-main STATIC ${SRC}) +# define the sfml-main target +add_library(sfml-main STATIC ${SRC}) - # set the debug suffix - set_target_properties(sfml-main PROPERTIES DEBUG_POSTFIX -d) +# set the debug suffix +set_target_properties(sfml-main PROPERTIES DEBUG_POSTFIX -d) - # insert the major version number in the output filename - set_target_properties(sfml-main PROPERTIES OUTPUT_NAME "sfml-main") +# insert the major version number in the output filename +set_target_properties(sfml-main PROPERTIES OUTPUT_NAME "sfml-main") - # set the target's folder (for IDEs that support it, e.g. Visual Studio) - set_target_properties(sfml-main PROPERTIES FOLDER "SFML") +# set the target's folder (for IDEs that support it, e.g. Visual Studio) +set_target_properties(sfml-main PROPERTIES FOLDER "SFML") - # setup the install rule - install(TARGETS sfml-main ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT devel) -else() - # define the sfml-main target - sfml_add_library(sfml-main SOURCES ${SRC} DEPENDS sfml-window sfml-system) -endif() +# setup the install rule +install(TARGETS sfml-main ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT devel) diff --git a/src/SFML/Main/MainAndroid.cpp b/src/SFML/Main/MainAndroid.cpp index 97f02e8a3..052bc04f8 100644 --- a/src/SFML/Main/MainAndroid.cpp +++ b/src/SFML/Main/MainAndroid.cpp @@ -27,15 +27,15 @@ #ifdef SFML_SYSTEM_ANDROID +#include +#include #include #include #include #include -#include + extern int main(int argc, char *argv[]); -JavaVM* javaVM; - namespace sf { @@ -292,16 +292,6 @@ void processSensorEvents(ActivityStates* states) } } -ActivityStates* getActivityStates(ActivityStates* initializedStates) -{ - static ActivityStates* states = NULL; - - if (!states) - states = initializedStates; - - return states; -} - ActivityStates* retrieveStates(ANativeActivity* activity) { // Hide the ugly cast we find in each callback function @@ -578,9 +568,6 @@ static void onLowMemory(ANativeActivity* activity) void ANativeActivity_onCreate(ANativeActivity* activity, void* savedState, size_t savedStateSize) { - // Feed OpenAL-Soft's javaVM to make so he can function - javaVM = activity->vm; - // Create an activity states (will keep us in the know, about events we care) sf::priv::ActivityStates* states = NULL; states = new sf::priv::ActivityStates; @@ -610,7 +597,7 @@ void ANativeActivity_onCreate(ANativeActivity* activity, void* savedState, size_ states->terminated = false; // Share it across the SFML modules - sf::priv::getActivityStates(states); + sf::priv::getActivity(states); // These functions will update the activity states and therefore, will allow // SFML to be kept in the know diff --git a/src/SFML/Network/Android.mk b/src/SFML/Network/Android.mk deleted file mode 100644 index 895f1a260..000000000 --- a/src/SFML/Network/Android.mk +++ /dev/null @@ -1,17 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE := sfml-network - -LOCAL_SRC_FILES := Ftp.cpp -LOCAL_SRC_FILES += Http.cpp -LOCAL_SRC_FILES += IpAddress.cpp -LOCAL_SRC_FILES += Packet.cpp -LOCAL_SRC_FILES += Socket.cpp -LOCAL_SRC_FILES += SocketSelector.cpp -LOCAL_SRC_FILES += TcpListener.cpp -LOCAL_SRC_FILES += TcpSocket.cpp -LOCAL_SRC_FILES += UdpSocket.cpp -LOCAL_SRC_FILES += Unix/SocketImpl.cpp - -include $(BUILD_STATIC_LIBRARY) diff --git a/src/SFML/System/Android.mk b/src/SFML/System/Android.mk deleted file mode 100644 index 685655ba9..000000000 --- a/src/SFML/System/Android.mk +++ /dev/null @@ -1,21 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE := sfml-system - -LOCAL_SRC_FILES := Clock.cpp -LOCAL_SRC_FILES += Err.cpp -LOCAL_SRC_FILES += Lock.cpp -LOCAL_SRC_FILES += Mutex.cpp -LOCAL_SRC_FILES += Sleep.cpp -LOCAL_SRC_FILES += String.cpp -LOCAL_SRC_FILES += Thread.cpp -LOCAL_SRC_FILES += ThreadLocal.cpp -LOCAL_SRC_FILES += Time.cpp -LOCAL_SRC_FILES += Unix/ClockImpl.cpp -LOCAL_SRC_FILES += Unix/MutexImpl.cpp -LOCAL_SRC_FILES += Unix/SleepImpl.cpp -LOCAL_SRC_FILES += Unix/ThreadImpl.cpp -LOCAL_SRC_FILES += Unix/ThreadLocalImpl.cpp - -include $(BUILD_STATIC_LIBRARY) diff --git a/src/SFML/System/CMakeLists.txt b/src/SFML/System/CMakeLists.txt index f0ae3f00b..7aa88d877 100644 --- a/src/SFML/System/CMakeLists.txt +++ b/src/SFML/System/CMakeLists.txt @@ -70,8 +70,8 @@ else() endif() # build the list of external libraries to link -set(SYSTEM_EXT_LIBS) -if(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_MACOSX) +set(SYSTEM_EXT_LIBS) +if(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_MACOSX) set(SYSTEM_EXT_LIBS ${SYSTEM_EXT_LIBS} pthread) endif() if(SFML_OS_LINUX) @@ -81,6 +81,11 @@ if(SFML_OS_WINDOWS) set(SYSTEM_EXT_LIBS ${SYSTEM_EXT_LIBS} winmm) endif() +# pthread is implicitly linked by the NDK +if(ANDROID) + set(SYSTEM_EXT_LIBS "") +endif() + # define the sfml-system target sfml_add_library(sfml-system SOURCES ${SRC} ${PLATFORM_SRC} diff --git a/src/SFML/Window/Android.mk b/src/SFML/Window/Android.mk deleted file mode 100644 index 0b5f0ac9f..000000000 --- a/src/SFML/Window/Android.mk +++ /dev/null @@ -1,23 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE := sfml-window - -LOCAL_SRC_FILES := Context.cpp -LOCAL_SRC_FILES += GlContext.cpp -LOCAL_SRC_FILES += GlResource.cpp -LOCAL_SRC_FILES += Joystick.cpp -LOCAL_SRC_FILES += JoystickManager.cpp -LOCAL_SRC_FILES += Keyboard.cpp -LOCAL_SRC_FILES += Mouse.cpp -LOCAL_SRC_FILES += VideoMode.cpp -LOCAL_SRC_FILES += Window.cpp -LOCAL_SRC_FILES += WindowImpl.cpp -LOCAL_SRC_FILES += EGLCheck.cpp -LOCAL_SRC_FILES += Android/WindowImplAndroid.cpp -LOCAL_SRC_FILES += Android/EglContext.cpp -LOCAL_SRC_FILES += Android/VideoModeImpl.cpp -LOCAL_SRC_FILES += Android/InputImpl.cpp -LOCAL_SRC_FILES += Android/JoystickImpl.cpp - -include $(BUILD_STATIC_LIBRARY) diff --git a/src/SFML/Window/Android/Activity.cpp b/src/SFML/Window/Android/Activity.cpp new file mode 100644 index 000000000..236b1b06a --- /dev/null +++ b/src/SFML/Window/Android/Activity.cpp @@ -0,0 +1,41 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2013 Jonathan De Wachter (dewachter.jonathan@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#include + +namespace sf +{ +namespace priv +{ + ActivityStates* getActivity(ActivityStates* initializedStates) + { + static ActivityStates* states = NULL; + + if (!states) + states = initializedStates; + + return states; + } +} +} diff --git a/include/SFML/Main/activity.hpp b/src/SFML/Window/Android/Activity.hpp similarity index 94% rename from include/SFML/Main/activity.hpp rename to src/SFML/Window/Android/Activity.hpp index c98731954..7de7875a3 100644 --- a/include/SFML/Main/activity.hpp +++ b/src/SFML/Window/Android/Activity.hpp @@ -28,14 +28,13 @@ //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// +#include +#include #include #include #include -#include -#include -#include #include - +#include namespace sf { @@ -71,7 +70,7 @@ struct ActivityStates bool updated; }; -ActivityStates* getActivityStates(ActivityStates* initializedStates=NULL); +SFML_WINDOW_API ActivityStates* getActivity(ActivityStates* initializedStates=NULL); } // namespace priv } // namespace sf diff --git a/src/SFML/Window/Android/EglContext.cpp b/src/SFML/Window/Android/EglContext.cpp index 6f435dbd8..5d6e4e6dc 100644 --- a/src/SFML/Window/Android/EglContext.cpp +++ b/src/SFML/Window/Android/EglContext.cpp @@ -27,12 +27,12 @@ // Headers //////////////////////////////////////////////////////////// #include +#include #include #include #include #include #include -#include #include @@ -47,7 +47,7 @@ m_context (EGL_NO_CONTEXT), m_surface (EGL_NO_SURFACE) { // Get the activity states and protect it from concurent access - ActivityStates* states = getActivityStates(NULL); + ActivityStates* states = getActivity(NULL); sf::Lock lock(states->mutex); // Get the intialized EGL display @@ -84,7 +84,7 @@ m_context (EGL_NO_CONTEXT), m_surface (EGL_NO_SURFACE) { // Get the activity states and protect it from concurent access - ActivityStates* states = getActivityStates(NULL); + ActivityStates* states = getActivity(NULL); sf::Lock lock(states->mutex); // Get the intialized EGL display diff --git a/src/SFML/Window/Android/InputImpl.cpp b/src/SFML/Window/Android/InputImpl.cpp index 905a62e2f..e99cb73e1 100644 --- a/src/SFML/Window/Android/InputImpl.cpp +++ b/src/SFML/Window/Android/InputImpl.cpp @@ -26,8 +26,8 @@ // Headers //////////////////////////////////////////////////////////// #include +#include #include -#include #include @@ -47,7 +47,7 @@ void InputImpl::setVirtualKeyboardVisible(bool visible) { // TODO: Check if the window is active - ActivityStates* states = getActivityStates(NULL); + ActivityStates* states = getActivity(NULL); sf::Lock lock(states->mutex); jint lResult; diff --git a/src/SFML/Window/Android/VideoModeImpl.cpp b/src/SFML/Window/Android/VideoModeImpl.cpp index c2aa51ea1..2d701602f 100644 --- a/src/SFML/Window/Android/VideoModeImpl.cpp +++ b/src/SFML/Window/Android/VideoModeImpl.cpp @@ -26,11 +26,10 @@ // Headers //////////////////////////////////////////////////////////// #include +#include #include #include #include -#include - namespace sf { @@ -53,7 +52,7 @@ std::vector VideoModeImpl::getFullscreenModes() VideoMode VideoModeImpl::getDesktopMode() { // Get the activity states - priv::ActivityStates* states = priv::getActivityStates(NULL); + priv::ActivityStates* states = priv::getActivity(NULL); Lock lock(states->mutex); // Wait for a window if there's none diff --git a/src/SFML/Window/Android/WindowImplAndroid.cpp b/src/SFML/Window/Android/WindowImplAndroid.cpp index b70f210e2..8ffe3aca9 100644 --- a/src/SFML/Window/Android/WindowImplAndroid.cpp +++ b/src/SFML/Window/Android/WindowImplAndroid.cpp @@ -29,12 +29,10 @@ #include // important to be included first (conflict with None) #include #include +#include #include -#include -#include -#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "sfml_app", __VA_ARGS__)) //////////////////////////////////////////////////////////// // Private data //////////////////////////////////////////////////////////// @@ -72,7 +70,7 @@ WindowHandle WindowImplAndroid::getSystemHandle() const //////////////////////////////////////////////////////////// void WindowImplAndroid::processEvents() { - ActivityStates* states = getActivityStates(NULL); + ActivityStates* states = getActivity(NULL); sf::Lock lock(states->mutex); int ident, events; diff --git a/src/SFML/Window/CMakeLists.txt b/src/SFML/Window/CMakeLists.txt index 2464333e1..fedd7a500 100644 --- a/src/SFML/Window/CMakeLists.txt +++ b/src/SFML/Window/CMakeLists.txt @@ -141,22 +141,24 @@ elseif(ANDROID) set(PLATFORM_SRC ${SRCROOT}/Android/WindowImplAndroid.hpp ${SRCROOT}/Android/WindowImplAndroid.cpp - ${SRCROOT}/Android/EGLContext.hpp - ${SRCROOT}/Android/EGLContext.cpp - ${SRCROOT}/Android/VideoModeImpl.hpp + ${SRCROOT}/Android/EglContext.hpp + ${SRCROOT}/Android/EglContext.cpp + #${SRCROOT}/Android/VideoModeImpl.hpp ${SRCROOT}/Android/VideoModeImpl.cpp ${SRCROOT}/Android/InputImpl.hpp ${SRCROOT}/Android/InputImpl.cpp ${SRCROOT}/Android/JoystickImpl.hpp - ${SRCROOT}/Android/JoystickImpl.cpp) + ${SRCROOT}/Android/JoystickImpl.cpp + ${SRCROOT}/Android/Activity.hpp + ${SRCROOT}/Android/Activity.cpp) source_group("android" FILES ${PLATFORM_SRC}) endif() # find external libraries if(NOT OPENGL_ES) find_package(OpenGL REQUIRED) - include_directories(${OPENGL_INCLUDE_DIR}) - if(SFML_OS_LINUX) + include_directories(${OPENGL_INCLUDE_DIR}) + if(SFML_OS_LINUX AND NOT SFML_OS_ANDROID) find_package(X11 REQUIRED) if(NOT X11_Xrandr_FOUND) message(FATAL_ERROR "Xrandr library not found") @@ -181,9 +183,11 @@ elseif(SFML_OS_LINUX OR SFML_OS_FREEBSD) set(WINDOW_EXT_LIBS ${WINDOW_EXT_LIBS} usbhid) endif() elseif(SFML_OS_MACOSX) - set(WINDOW_EXT_LIBS ${WINDOW_EXT_LIBS} ${OPENGL_gl_LIBRARY} "-framework Foundation -framework AppKit -framework IOKit -framework Carbon") -elseif(SFML_OS_IOS) - set(WINDOW_EXT_LIBS ${WINDOW_EXT_LIBS} "-framework OpenGLES -framework Foundation -framework UIKit -framework CoreGraphics -framework QuartzCore -framework CoreMotion") + set(WINDOW_EXT_LIBS ${WINDOW_EXT_LIBS} ${OPENGL_gl_LIBRARY} "-framework Foundation -framework AppKit -framework IOKit -framework Carbon") +elseif(SFML_OS_IOS) + set(WINDOW_EXT_LIBS ${WINDOW_EXT_LIBS} "-framework OpenGLES -framework Foundation -framework UIKit -framework CoreGraphics -framework QuartzCore -framework CoreMotion") +elseif(SFML_OS_ANDROID) + set(WINDOW_EXT_LIBS ${WINDOW_EXT_LIBS} "-landroid -llog -lEGL -lGLESv1_CM") endif() # define the sfml-window target diff --git a/src/SFML/Window/Window.cpp b/src/SFML/Window/Window.cpp index 90ba727dd..f86e5bcce 100644 --- a/src/SFML/Window/Window.cpp +++ b/src/SFML/Window/Window.cpp @@ -35,6 +35,7 @@ #include #endif + namespace { const sf::Window* fullscreenWindow = NULL;