From d5d58656150e58b9fcebbaeed81f6c00c983f883 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 23 Jun 2019 17:10:57 -0700 Subject: [PATCH] Move strtod_l check to CMake since it's very system-specific --- CMakeLists.txt | 11 +++++++++++ include/fmt/posix.h | 6 ------ test/CMakeLists.txt | 3 +++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ed14463..6214d5a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -127,11 +127,18 @@ if (MASTER_PROJECT AND CMAKE_GENERATOR MATCHES "Visual Studio") ${CMAKE_MAKE_PROGRAM} -p:FrameworkPathOverride=\"${netfxpath}\" %*") endif () +set(strtod_l_headers stdlib.h) +if (APPLE) + set(strtod_l_headers ${strtod_l_headers} xlocale.h) +endif () + include(CheckSymbolExists) if (WIN32) check_symbol_exists(open io.h HAVE_OPEN) + check_symbol_exists(_strtod_l "${strtod_l_headers}" HAVE_STRTOD_L) else () check_symbol_exists(open fcntl.h HAVE_OPEN) + check_symbol_exists(strtod_l "${strtod_l_headers}" HAVE_STRTOD_L) endif () function(add_headers VAR) @@ -154,6 +161,10 @@ endif () add_library(fmt ${FMT_SOURCES} ${FMT_HEADERS} README.rst ChangeLog.rst) add_library(fmt::fmt ALIAS fmt) +if (HAVE_STRTOD_L) + target_compile_definitions(fmt PUBLIC FMT_LOCALE) +endif () + if (FMT_WERROR) target_compile_options(fmt PRIVATE ${WERROR_FLAG}) endif () diff --git a/include/fmt/posix.h b/include/fmt/posix.h index 68f6995d..e5394f40 100644 --- a/include/fmt/posix.h +++ b/include/fmt/posix.h @@ -261,12 +261,6 @@ class file { // Returns the memory page size. long getpagesize(); -#if (defined(LC_NUMERIC_MASK) || defined(_MSC_VER)) && \ - !defined(__ANDROID__) && !defined(__CYGWIN__) && !defined(__OpenBSD__) && \ - !defined(__NEWLIB_H__) -# define FMT_LOCALE -#endif - #ifdef FMT_LOCALE // A "C" numeric locale. class Locale { diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ace5ed67..f2ee8098 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -118,6 +118,9 @@ if (HAVE_OPEN) if (FMT_PEDANTIC) target_compile_options(posix-mock-test PRIVATE ${PEDANTIC_COMPILE_FLAGS}) endif () + if (HAVE_STRTOD_L) + target_compile_definitions(posix-mock-test PRIVATE FMT_LOCALE) + endif () add_test(NAME posix-mock-test COMMAND posix-mock-test) add_fmt_test(posix-test) endif ()