cmake: check and use clock_gettime by default on android
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f40005f..4c2c4c8 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)