Android build fixes
authorOlli Kallioinen <olli.kallioinen@iki.fi>
Thu, 08 Jun 2017 22:07:55 +0300
changeset 112074ed2e42b7497
parent 11206 946452867513
child 11208 3d59240ebfd9
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
CMakeLists.txt
cmake/sdlchecks.cmake
     1.1 --- a/CMakeLists.txt	Wed Aug 09 16:20:04 2017 -0700
     1.2 +++ b/CMakeLists.txt	Thu Jun 08 22:07:55 2017 +0300
     1.3 @@ -159,6 +159,10 @@
     1.4    set(OPT_DEF_ASM FALSE)
     1.5  endif()
     1.6  
     1.7 +if(USE_GCC OR USE_CLANG)
     1.8 +  set(OPT_DEF_GCC_ATOMICS ON)
     1.9 +endif()
    1.10 +
    1.11  # Default flags, if not set otherwise
    1.12  if("$ENV{CFLAGS}" STREQUAL "")
    1.13    if(CMAKE_BUILD_TYPE STREQUAL "")
    1.14 @@ -257,7 +261,7 @@
    1.15  option_string(ASSERTIONS "Enable internal sanity checks (auto/disabled/release/enabled/paranoid)" "auto")
    1.16  #set_option(DEPENDENCY_TRACKING "Use gcc -MMD -MT dependency tracking" ON)
    1.17  set_option(LIBC                "Use the system C library" ${OPT_DEF_LIBC})
    1.18 -set_option(GCC_ATOMICS         "Use gcc builtin atomics" ${USE_GCC})
    1.19 +set_option(GCC_ATOMICS         "Use gcc builtin atomics" ${OPT_DEF_GCC_ATOMICS})
    1.20  set_option(ASSEMBLY            "Enable assembly routines" ${OPT_DEF_ASM})
    1.21  set_option(SSEMATH             "Allow GCC to use SSE floating point math" ${OPT_DEF_SSEMATH})
    1.22  set_option(MMX                 "Use MMX assembly routines" ${OPT_DEF_ASM})
    1.23 @@ -792,12 +796,24 @@
    1.24      set(SOURCE_FILES ${SOURCE_FILES} ${ANDROID_JOYSTICK_SOURCES})
    1.25      set(HAVE_SDL_JOYSTICK TRUE)
    1.26    endif()
    1.27 +  if(SDL_LOADSO)
    1.28 +    set(SDL_LOADSO_DLOPEN 1)
    1.29 +    file(GLOB LOADSO_SOURCES ${SDL2_SOURCE_DIR}/src/loadso/dlopen/*.c)
    1.30 +    set(SOURCE_FILES ${SOURCE_FILES} ${LOADSO_SOURCES})
    1.31 +    set(HAVE_SDL_LOADSO TRUE)
    1.32 +  endif()
    1.33    if(SDL_POWER)
    1.34      set(SDL_POWER_ANDROID 1)
    1.35      file(GLOB ANDROID_POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/android/*.c)
    1.36      set(SOURCE_FILES ${SOURCE_FILES} ${ANDROID_POWER_SOURCES})
    1.37      set(HAVE_SDL_POWER TRUE)
    1.38    endif()
    1.39 +  if(SDL_TIMERS)
    1.40 +    set(SDL_TIMER_UNIX 1)
    1.41 +    file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/unix/*.c)
    1.42 +    set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES})
    1.43 +    set(HAVE_SDL_TIMERS TRUE)
    1.44 +  endif()
    1.45    if(SDL_VIDEO)
    1.46      set(SDL_VIDEO_DRIVER_ANDROID 1)
    1.47      file(GLOB ANDROID_VIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/android/*.c)
    1.48 @@ -823,6 +839,9 @@
    1.49        list(APPEND EXTRA_LIBS ${OpenGLES1_LIBRARY} ${OpenGLES2_LIBRARY})
    1.50      endif()
    1.51    endif()
    1.52 +
    1.53 +  CheckPTHREAD()
    1.54 +
    1.55    list(APPEND EXTRA_LDFLAGS "-Wl,--undefined=Java_org_libsdl_app_SDLActivity_nativeInit")
    1.56  endif()
    1.57  
     2.1 --- a/cmake/sdlchecks.cmake	Wed Aug 09 16:20:04 2017 -0700
     2.2 +++ b/cmake/sdlchecks.cmake	Thu Jun 08 22:07:55 2017 +0300
     2.3 @@ -859,6 +859,8 @@
     2.4      if(LINUX)
     2.5        set(PTHREAD_CFLAGS "-D_REENTRANT")
     2.6        set(PTHREAD_LDFLAGS "-pthread")
     2.7 +    elseif(ANDROID)
     2.8 +      # pthreads are builtin
     2.9      elseif(BSDI)
    2.10        set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE")
    2.11        set(PTHREAD_LDFLAGS "")