From 380bae80bf3e3b317b4b58bb73137831daace7e2 Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Wed, 2 Jan 2019 19:07:53 -0600 Subject: [PATCH] Fix `wcstod_l` detection under Linux This was broken in a8eb02f9f59350f222295e16b8f68dc3b45d9ed5 when the detection was corrected for FreeBSD. This patch makes the detection work for both Linux and FreeBSD instead of one or the other (tested). --- cmake/ConfigureChecks.cmake | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake index a9ddf674d..da783a6ea 100644 --- a/cmake/ConfigureChecks.cmake +++ b/cmake/ConfigureChecks.cmake @@ -90,9 +90,17 @@ CHECK_CXX_SYMBOL_EXISTS(wcsncasecmp wchar.h HAVE_WCSNCASECMP) CHECK_CXX_SYMBOL_EXISTS(wcsndup wchar.h HAVE_WCSNDUP) CMAKE_PUSH_CHECK_STATE(RESET) -# wcstod_l is a GNU-extension, sometimes hidden behind the following define +# `wcstod_l` is a GNU-extension, sometimes hidden behind the following define LIST(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE=1) -CHECK_CXX_SYMBOL_EXISTS(wcstod_l "wchar.h;xlocale.h" HAVE_WCSTOD_L) +# `xlocale.h` is required to find `wcstod_l` in `wchar.h` under FreeBSD, but +# it's not present under Linux. +SET(WCSTOD_L_INCLUDES "") +CHECK_INCLUDE_FILES("xlocale.h" HAVE_XLOCALE_H) +IF(HAVE_XLOCALE_H) + LIST(APPEND WCSTOD_L_INCLUDES "xlocale.h") +ENDIF() +LIST(APPEND WCSTOD_L_INCLUDES "wchar.h") +CHECK_CXX_SYMBOL_EXISTS(wcstod_l "${WCSTOD_L_INCLUDES}" HAVE_WCSTOD_L) CMAKE_POP_CHECK_STATE() CHECK_CXX_SYMBOL_EXISTS(_sys_errs stdlib.h HAVE__SYS__ERRS)