From 74058d40d6dfd5e97ae71356beb8104839691cd4 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Fri, 24 Apr 2026 02:14:13 +0200
Subject: [PATCH] cmake: also check iconv on Windows when SDL_SYSTEM_ICONV is
defined
(cherry picked from commit 929e304b18796bf4db74f60f024a5e206f58d31b)
---
CMakeLists.txt | 51 +++++++++++++++++++++++++-------------------------
1 file changed, 25 insertions(+), 26 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 18258e513b7c4..4032ae305cc86 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1179,34 +1179,33 @@ if(SDL_LIBC)
check_symbol_exists(posix_fallocate "fcntl.h" HAVE_POSIX_FALLOCATE)
check_symbol_exists(posix_spawn_file_actions_addchdir "spawn.h" HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR)
check_symbol_exists(posix_spawn_file_actions_addchdir_np "spawn.h" HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR_NP)
+ endif()
+ if(SDL_SYSTEM_ICONV)
+ check_c_source_compiles("
+ #define LIBICONV_PLUG 1 /* in case libiconv header is in include path */
+ #include <stddef.h>
+ #include <iconv.h>
+ int main(int argc, char **argv) {
+ return !iconv_open(NULL,NULL);
+ }" ICONV_IN_LIBC)
- if(SDL_SYSTEM_ICONV)
- check_c_source_compiles("
- #define LIBICONV_PLUG 1 /* in case libiconv header is in include path */
- #include <stddef.h>
- #include <iconv.h>
- int main(int argc, char **argv) {
- return !iconv_open(NULL,NULL);
- }" ICONV_IN_LIBC)
-
- cmake_push_check_state()
- list(APPEND CMAKE_REQUIRED_LIBRARIES iconv)
- check_c_source_compiles("
- #include <stddef.h>
- #include <iconv.h>
- int main(int argc, char **argv) {
- return !iconv_open(NULL,NULL);
- }" ICONV_IN_LIBICONV)
- cmake_pop_check_state()
+ cmake_push_check_state()
+ list(APPEND CMAKE_REQUIRED_LIBRARIES iconv)
+ check_c_source_compiles("
+ #include <stddef.h>
+ #include <iconv.h>
+ int main(int argc, char **argv) {
+ return !iconv_open(NULL,NULL);
+ }" ICONV_IN_LIBICONV)
+ cmake_pop_check_state()
- if(ICONV_IN_LIBC OR ICONV_IN_LIBICONV)
- set(HAVE_ICONV 1)
- set(HAVE_SYSTEM_ICONV TRUE)
- if(ICONV_IN_LIBICONV AND (SDL_LIBICONV OR (NOT ICONV_IN_LIBC)))
- sdl_link_dependency(iconv LIBS iconv)
- set(SDL_USE_LIBICONV 1)
- set(HAVE_LIBICONV TRUE)
- endif()
+ if(ICONV_IN_LIBC OR ICONV_IN_LIBICONV)
+ set(HAVE_ICONV 1)
+ set(HAVE_SYSTEM_ICONV TRUE)
+ if(ICONV_IN_LIBICONV AND (SDL_LIBICONV OR (NOT ICONV_IN_LIBC)))
+ sdl_link_dependency(iconv LIBS iconv)
+ set(SDL_USE_LIBICONV 1)
+ set(HAVE_LIBICONV TRUE)
endif()
endif()