Allow emscripten platform to build without threads
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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8869ad6..ab62ba0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2711,10 +2711,14 @@ endif()
# We always need to have threads and timers around
if(NOT HAVE_SDL_THREADS)
- message_error("Threads are needed by many SDL subsystems and may not be disabled")
- #set(SDL_THREADS_DISABLED 1)
- #file(GLOB THREADS_SOURCES ${SDL2_SOURCE_DIR}/src/thread/generic/*.c)
- #list(APPEND SOURCE_FILES ${THREADS_SOURCES})
+ # The emscripten platform has been carefully vetted to work without threads
+ if (EMSCRIPTEN)
+ set(SDL_THREADS_DISABLED 1)
+ file(GLOB THREADS_SOURCES ${SDL2_SOURCE_DIR}/src/thread/generic/*.c)
+ list(APPEND SOURCE_FILES ${THREADS_SOURCES})
+ else()
+ message_error("Threads are needed by many SDL subsystems and may not be disabled")
+ endif()
endif()
if(NOT HAVE_SDL_TIMERS)
set(SDL_TIMER_DUMMY 1)
diff --git a/configure b/configure
index 6f65b6e..cec4442 100755
--- a/configure
+++ b/configure
@@ -852,7 +852,6 @@ enable_hidapi
enable_sensor
enable_power
enable_filesystem
-enable_threads
enable_timers
enable_file
enable_misc
@@ -1643,7 +1642,6 @@ Optional Features:
--enable-sensor Enable the sensor subsystem [default=yes]
--enable-power Enable the power subsystem [default=yes]
--enable-filesystem Enable the filesystem subsystem [default=yes]
- --enable-threads Enable the threading subsystem [default=yes]
--enable-timers Enable the timer subsystem [default=yes]
--enable-file Enable the file subsystem [default=yes]
--enable-misc Enable the misc subsystem [default=yes]
@@ -20351,14 +20349,11 @@ printf "%s\n" "#define SDL_FILESYSTEM_DISABLED 1" >>confdefs.h
else
SUMMARY_modules="${SUMMARY_modules} filesystem"
fi
-# Check whether --enable-threads was given.
-if test ${enable_threads+y}
-then :
- enableval=$enable_threads;
-else $as_nop
- enable_threads=yes
-fi
-
+# Many subsystems depend on threads, so leave them enabled by default
+#AC_ARG_ENABLE(threads,
+#[AS_HELP_STRING([--enable-threads], [Enable the threading subsystem [default=yes]])],
+# , enable_threads=yes)
+enable_threads=yes
if test x$enable_threads != xyes; then
printf "%s\n" "#define SDL_THREADS_DISABLED 1" >>confdefs.h
diff --git a/configure.ac b/configure.ac
index 5d59cd9..af97cec 100644
--- a/configure.ac
+++ b/configure.ac
@@ -526,11 +526,12 @@ fi
#AC_ARG_ENABLE(threads,
#[AS_HELP_STRING([--enable-threads], [Enable the threading subsystem [default=yes]])],
# , enable_threads=yes)
-#if test x$enable_threads != xyes; then
-# AC_DEFINE(SDL_THREADS_DISABLED, 1, [ ])
-#else
-# SUMMARY_modules="${SUMMARY_modules} threads"
-#fi
+enable_threads=yes
+if test x$enable_threads != xyes; then
+ AC_DEFINE(SDL_THREADS_DISABLED, 1, [ ])
+else
+ SUMMARY_modules="${SUMMARY_modules} threads"
+fi
AC_ARG_ENABLE(timers,
[AS_HELP_STRING([--enable-timers], [Enable the timer subsystem [default=yes]])],
, enable_timers=yes)