SDL: autotools, cmake: set SDL_SYSTEM_ICONV to OFF for windows (like SDL3.)

From 8cf7e9e7da7f19f1a0f05deeaff834189afd518f Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Thu, 23 Nov 2023 01:33:50 +0300
Subject: [PATCH] autotools, cmake: set SDL_SYSTEM_ICONV to OFF for windows
 (like SDL3.)

---
 CMakeLists.txt |  7 ++++++-
 configure      | 10 ++++++++--
 configure.ac   | 10 ++++++++--
 3 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 334f98756a6e..14900486664d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -241,6 +241,11 @@ endif()
 if(UNIX OR MINGW OR MSYS OR (USE_CLANG AND NOT WINDOWS) OR VITA OR PSP OR PS2 OR N3DS)
   set(OPT_DEF_LIBC ON)
 endif()
+if(WINDOWS)
+  set(SDL_SYSTEM_ICONV_DEFAULT OFF)
+else()
+  set(SDL_SYSTEM_ICONV_DEFAULT ON)
+endif()
 
 if(NOT ("$ENV{CFLAGS}" STREQUAL ""))
   if(CMAKE_VERSION VERSION_LESS 3.11.0)
@@ -420,7 +425,7 @@ set_option(SDL_DIRECTFB            "Use DirectFB video driver" OFF)
 dep_option(SDL_DIRECTFB_SHARED     "Dynamically load directfb support" ON "SDL_DIRECTFB" OFF)
 set_option(SDL_DUMMYVIDEO          "Use dummy video driver" ON)
 dep_option(SDL_IBUS                "Enable IBus support" ON ${UNIX_SYS} OFF)
-set_option(SDL_SYSTEM_ICONV        "Use iconv() from system-installed libraries" ON)
+set_option(SDL_SYSTEM_ICONV        "Use iconv() from system-installed libraries" ${SDL_SYSTEM_ICONV_DEFAULT})
 set_option(SDL_LIBICONV            "Prefer iconv() from libiconv, if available, over libc version" OFF)
 set_option(SDL_OPENGL              "Include OpenGL support" ON)
 set_option(SDL_OPENGLES            "Include OpenGL ES support" ON)
diff --git a/configure b/configure
index 3120c796877c..06ea03ee30ae 100755
--- a/configure
+++ b/configure
@@ -1642,7 +1642,7 @@ Optional Features:
                           Use gcc -MMD -MT dependency tracking [default=yes]
   --enable-libc           Use the system C library [default=yes]
   --enable-system-iconv   Use iconv() from system-installed libraries
-                          [default=yes]
+                          [default=no for windows, yes for others]
   --enable-libiconv       Prefer iconv() from libiconv, if available, over
                           libc version [default=no]
   --enable-gcc-atomics    Use gcc builtin atomics [default=yes]
@@ -18823,12 +18823,18 @@ else $as_nop
 fi
 
 
+enable_system_iconv_default=yes
+case "$host" in
+  *-*-cygwin*|*-*-mingw*)
+    enable_system_iconv_default=no
+    ;;
+esac
 # Check whether --enable-system-iconv was given.
 if test ${enable_system_iconv+y}
 then :
   enableval=$enable_system_iconv;
 else $as_nop
-  enable_system_iconv=yes
+  enable_system_iconv=$enable_system_iconv_default
 fi
 
 # Check whether --enable-libiconv was given.
diff --git a/configure.ac b/configure.ac
index bf833cb6aa04..0429bf01fa1b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -320,9 +320,15 @@ AC_ARG_ENABLE(libc,
               , enable_libc=yes)
 
 dnl See whether we are allowed to use system iconv
+enable_system_iconv_default=yes
+case "$host" in
+  *-*-cygwin*|*-*-mingw*)
+    enable_system_iconv_default=no
+    ;;
+esac
 AC_ARG_ENABLE(system-iconv,
-[AS_HELP_STRING([--enable-system-iconv], [Use iconv() from system-installed libraries [default=yes]])],
-              , enable_system_iconv=yes)
+[AS_HELP_STRING([--enable-system-iconv], [Use iconv() from system-installed libraries [default=no for windows, yes for others]])],
+              , enable_system_iconv=$enable_system_iconv_default)
 dnl See whether we prefer libiconv over libc
 AC_ARG_ENABLE(libiconv,
 [AS_HELP_STRING([--enable-libiconv], [Prefer iconv() from libiconv, if available, over libc version [default=no]])],