revise iconv detection:
- check libiconv with a linkage test with iconv.h included - check libc iconv with a linkage test with iconv.h included and LIBICONV_PLUG defined (in case libiconv header is in include path) - add new configuration option to prefer iconv from libiconv, if available, over the libc version: SDL_LIBICONV, defaults to disabled. - remove FindIconv + pkg_check_modules for iconv, and use our manual iconv finding only - change FreeBSD specific LIBICONV_PLUG define in SDL_iconv.c to configuration result.main
parent
a45b371de0
commit
42c8366fdc
|
@ -295,6 +295,7 @@ dep_option(SDL_LASX "Use LASX assembly routines" ON "SDL_ASSEMBLY
|
||||||
|
|
||||||
set_option(SDL_LIBC "Use the system C library" ${SDL_LIBC_DEFAULT})
|
set_option(SDL_LIBC "Use the system C library" ${SDL_LIBC_DEFAULT})
|
||||||
set_option(SDL_SYSTEM_ICONV "Use iconv() from system-installed libraries" ${SDL_SYSTEM_ICONV_DEFAULT})
|
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_GCC_ATOMICS "Use gcc builtin atomics" ${SDL_GCC_ATOMICS_DEFAULT})
|
set_option(SDL_GCC_ATOMICS "Use gcc builtin atomics" ${SDL_GCC_ATOMICS_DEFAULT})
|
||||||
dep_option(SDL_DBUS "Enable D-Bus support" ON ${UNIX_SYS} OFF)
|
dep_option(SDL_DBUS "Enable D-Bus support" ON ${UNIX_SYS} OFF)
|
||||||
set_option(SDL_DISKAUDIO "Support the disk writer audio driver" ON)
|
set_option(SDL_DISKAUDIO "Support the disk writer audio driver" ON)
|
||||||
|
@ -1099,24 +1100,31 @@ if(SDL_LIBC)
|
||||||
check_symbol_exists(poll "poll.h" HAVE_POLL)
|
check_symbol_exists(poll "poll.h" HAVE_POLL)
|
||||||
|
|
||||||
if(SDL_SYSTEM_ICONV)
|
if(SDL_SYSTEM_ICONV)
|
||||||
check_library_exists(iconv iconv_open "" HAVE_LIBICONV)
|
check_c_source_compiles("
|
||||||
if(HAVE_LIBICONV)
|
#define LIBICONV_PLUG 1 /* in case libiconv header is in include path */
|
||||||
find_package(Iconv)
|
#include <stddef.h>
|
||||||
if(Iconv_FOUND AND NOT Iconv_IS_BUILT_IN)
|
#include <iconv.h>
|
||||||
set(HAVE_ICONV 1)
|
int main(int argc, char **argv) {
|
||||||
set(HAVE_SYSTEM_ICONV TRUE)
|
return iconv_open(NULL,NULL);
|
||||||
pkg_check_modules(PC_ICONV iconv)
|
}" ICONV_IN_LIBC)
|
||||||
if(PC_ICONV_FOUND)
|
|
||||||
sdl_link_dependency(iconv LIBS Iconv::Iconv CMAKE_MODULE Iconv PKG_CONFIG_SPECS iconv)
|
cmake_push_check_state()
|
||||||
else()
|
list(APPEND CMAKE_REQUIRED_LIBRARIES iconv)
|
||||||
sdl_link_dependency(iconv LIBS Iconv::Iconv CMAKE_MODULE Iconv PKG_CONFIG_LIBS iconv)
|
check_c_source_compiles("
|
||||||
endif()
|
#include <stddef.h>
|
||||||
endif()
|
#include <iconv.h>
|
||||||
else()
|
int main(int argc, char **argv) {
|
||||||
check_library_exists(c iconv_open "" HAVE_BUILTIN_ICONV)
|
return iconv_open(NULL,NULL);
|
||||||
if(HAVE_BUILTIN_ICONV)
|
}" ICONV_IN_LIBICONV)
|
||||||
|
cmake_pop_check_state()
|
||||||
|
|
||||||
|
if(ICONV_IN_LIBC OR ICONV_IN_LIBICONV)
|
||||||
set(HAVE_ICONV 1)
|
set(HAVE_ICONV 1)
|
||||||
set(HAVE_SYSTEM_ICONV TRUE)
|
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()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -196,6 +196,7 @@
|
||||||
#cmakedefine HAVE_CLOCK_GETTIME 1
|
#cmakedefine HAVE_CLOCK_GETTIME 1
|
||||||
#cmakedefine HAVE_GETPAGESIZE 1
|
#cmakedefine HAVE_GETPAGESIZE 1
|
||||||
#cmakedefine HAVE_ICONV 1
|
#cmakedefine HAVE_ICONV 1
|
||||||
|
#cmakedefine SDL_USE_LIBICONV 1
|
||||||
#cmakedefine HAVE_PTHREAD_SETNAME_NP 1
|
#cmakedefine HAVE_PTHREAD_SETNAME_NP 1
|
||||||
#cmakedefine HAVE_PTHREAD_SET_NAME_NP 1
|
#cmakedefine HAVE_PTHREAD_SET_NAME_NP 1
|
||||||
#cmakedefine HAVE_SEM_TIMEDWAIT 1
|
#cmakedefine HAVE_SEM_TIMEDWAIT 1
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
/* This file contains portable iconv functions for SDL */
|
/* This file contains portable iconv functions for SDL */
|
||||||
|
|
||||||
#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H)
|
#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H)
|
||||||
#ifdef __FreeBSD__
|
#ifndef SDL_USE_LIBICONV
|
||||||
/* Define LIBICONV_PLUG to use iconv from the base instead of ports and avoid linker errors. */
|
/* Define LIBICONV_PLUG to use iconv from the base instead of ports and avoid linker errors. */
|
||||||
#define LIBICONV_PLUG 1
|
#define LIBICONV_PLUG 1
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue