From ca30936314e1867c143475ea278988f82af95155 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Fri, 24 Jun 2022 14:41:06 +0200 Subject: [PATCH] cmake: check and use clock_gettime by default on android --- CMakeLists.txt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f40005f6d..4c2c4c89b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -203,6 +203,12 @@ else() set(SDL_PTHREADS_ENABLED_BY_DEFAULT OFF) endif() +if(UNIX_SYS OR ANDROID) + set(SDL_CLOCK_GETTIME_ENABLED_BY_DEFAULT ON) +else() + set(SDL_CLOCK_GETTIME_ENABLED_BY_DEFAULT OFF) +endif() + # The hidraw support doesn't catch Xbox, PS4 and Nintendo controllers, # so we'll just use libusb when it's available. libusb does not support iOS, # so we default to yes on iOS. @@ -445,7 +451,7 @@ dep_option(SDL_FUSIONSOUND_SHARED "Dynamically load fusionsound audio support" set_option(SDL_LIBSAMPLERATE "Use libsamplerate for audio rate conversion" ${UNIX_SYS}) dep_option(SDL_LIBSAMPLERATE_SHARED "Dynamically load libsamplerate" ON "SDL_LIBSAMPLERATE" OFF) set_option(SDL_RPATH "Use an rpath when linking SDL" ${UNIX_SYS}) -set_option(SDL_CLOCK_GETTIME "Use clock_gettime() instead of gettimeofday()" ${UNIX_SYS}) +set_option(SDL_CLOCK_GETTIME "Use clock_gettime() instead of gettimeofday()" ${SDL_CLOCK_GETTIME_ENABLED_BY_DEFAULT}) set_option(SDL_X11 "Use X11 video driver" ${UNIX_SYS}) dep_option(SDL_X11_SHARED "Dynamically load X11 support" ON "SDL_X11" OFF) set(SDL_X11_OPTIONS Xcursor Xdbe XInput Xfixes Xrandr Xscrnsaver XShape) @@ -1210,6 +1216,9 @@ if(ANDROID) endif() CheckPTHREAD() + if(SDL_CLOCK_GETTIME) + set(HAVE_CLOCK_GETTIME 1) + endif() elseif(EMSCRIPTEN) # Hide noisy warnings that intend to aid mostly during initial stages of porting a new @@ -1277,7 +1286,7 @@ elseif(EMSCRIPTEN) CheckPTHREAD() -elseif(UNIX AND NOT APPLE AND NOT ANDROID AND NOT RISCOS AND NOT HAIKU) +elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU) if(SDL_AUDIO) if(SYSV5 OR SOLARIS OR HPUX) set(SDL_AUDIO_DRIVER_SUNAUDIO 1)