diff --git a/CMakeLists.txt b/CMakeLists.txt index 2663b662d..0a3ffcbc0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -305,11 +305,13 @@ if(DEFINED 3DS) endif() include(CheckFunctionExists) +include(CheckIncludeFiles) check_function_exists(strdup HAVE_STRDUP) check_function_exists(strndup HAVE_STRNDUP) if(NOT DEFINED PSP2) check_function_exists(localtime_r HAVE_LOCALTIME_R) endif() +check_include_files("xlocale.h" HAVE_XLOCALE) if(NOT CMAKE_SYSTEM_NAME STREQUAL "Generic") check_function_exists(snprintf_l HAVE_SNPRINTF_L) if(CMAKE_SYSTEM_NAME STREQUAL "Linux") @@ -367,9 +369,6 @@ endif() if(HAVE_NEWLOCALE AND HAVE_FREELOCALE AND HAVE_USELOCALE OR APPLE) list(APPEND FUNCTION_DEFINES HAVE_LOCALE) - if (HAVE_STRTOF_L) - list(APPEND FUNCTION_DEFINES HAVE_STRTOF_L) - endif() if (HAVE_SNPRINTF_L) list(APPEND FUNCTION_DEFINES HAVE_SNPRINTF_L) endif() @@ -379,6 +378,14 @@ if(HAVE_SETLOCALE) list(APPEND FUNCTION_DEFINES HAVE_SETLOCALE) endif() +if (HAVE_STRTOF_L) + list(APPEND FUNCTION_DEFINES HAVE_STRTOF_L) +endif() + +if(HAVE_XLOCALE) + list(APPEND FUNCTION_DEFINES HAVE_XLOCALE) +endif() + if(HAVE_CHMOD) list(APPEND FUNCTION_DEFINES HAVE_CHMOD) endif() diff --git a/include/mgba-util/formatting.h b/include/mgba-util/formatting.h index 4395879aa..6eb01ffaf 100644 --- a/include/mgba-util/formatting.h +++ b/include/mgba-util/formatting.h @@ -12,8 +12,8 @@ CXX_GUARD_START #include "locale.h" -#if defined(__APPLE__) || defined(__FreeBSD__) -#include "xlocale.h" +#ifdef HAVE_XLOCALE +#include #elif !defined(HAVE_LOCALE) typedef const char* locale_t; #endif