Skip to content
Permalink
Browse files

Android build fixes

 -Enabling checking for GCC_ATOMICS also on clang by default. This way all Android ABIs build successfully
 -Android cmake: Threading was not enabled correctly
 -Android cmake: Timers and dynamic lib loading were not included in the sources
  • Loading branch information
suikki committed Jun 8, 2017
1 parent 53d4f5c commit 2b5a5c510b67b2097865b9ff446b2ba44837bdc6
Showing with 22 additions and 1 deletion.
  1. +20 −1 CMakeLists.txt
  2. +2 −0 cmake/sdlchecks.cmake
@@ -159,6 +159,10 @@ else()
set(OPT_DEF_ASM FALSE)
endif()

if(USE_GCC OR USE_CLANG)
set(OPT_DEF_GCC_ATOMICS ON)
endif()

# Default flags, if not set otherwise
if("$ENV{CFLAGS}" STREQUAL "")
if(CMAKE_BUILD_TYPE STREQUAL "")
@@ -257,7 +261,7 @@ endforeach()
option_string(ASSERTIONS "Enable internal sanity checks (auto/disabled/release/enabled/paranoid)" "auto")
#set_option(DEPENDENCY_TRACKING "Use gcc -MMD -MT dependency tracking" ON)
set_option(LIBC "Use the system C library" ${OPT_DEF_LIBC})
set_option(GCC_ATOMICS "Use gcc builtin atomics" ${USE_GCC})
set_option(GCC_ATOMICS "Use gcc builtin atomics" ${OPT_DEF_GCC_ATOMICS})
set_option(ASSEMBLY "Enable assembly routines" ${OPT_DEF_ASM})
set_option(SSEMATH "Allow GCC to use SSE floating point math" ${OPT_DEF_SSEMATH})
set_option(MMX "Use MMX assembly routines" ${OPT_DEF_ASM})
@@ -792,12 +796,24 @@ if(ANDROID)
set(SOURCE_FILES ${SOURCE_FILES} ${ANDROID_JOYSTICK_SOURCES})
set(HAVE_SDL_JOYSTICK TRUE)
endif()
if(SDL_LOADSO)
set(SDL_LOADSO_DLOPEN 1)
file(GLOB LOADSO_SOURCES ${SDL2_SOURCE_DIR}/src/loadso/dlopen/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${LOADSO_SOURCES})
set(HAVE_SDL_LOADSO TRUE)
endif()
if(SDL_POWER)
set(SDL_POWER_ANDROID 1)
file(GLOB ANDROID_POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/android/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${ANDROID_POWER_SOURCES})
set(HAVE_SDL_POWER TRUE)
endif()
if(SDL_TIMERS)
set(SDL_TIMER_UNIX 1)
file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/unix/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES})
set(HAVE_SDL_TIMERS TRUE)
endif()
if(SDL_VIDEO)
set(SDL_VIDEO_DRIVER_ANDROID 1)
file(GLOB ANDROID_VIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/android/*.c)
@@ -823,6 +839,9 @@ if(ANDROID)
list(APPEND EXTRA_LIBS ${OpenGLES1_LIBRARY} ${OpenGLES2_LIBRARY})
endif()
endif()

CheckPTHREAD()

list(APPEND EXTRA_LDFLAGS "-Wl,--undefined=Java_org_libsdl_app_SDLActivity_nativeInit")
endif()

@@ -859,6 +859,8 @@ macro(CheckPTHREAD)
if(LINUX)
set(PTHREAD_CFLAGS "-D_REENTRANT")
set(PTHREAD_LDFLAGS "-pthread")
elseif(ANDROID)
# pthreads are builtin
elseif(BSDI)
set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE")
set(PTHREAD_LDFLAGS "")

0 comments on commit 2b5a5c5

Please sign in to comment.