Skip to content

Commit 1839f2d

Browse files
committed
Check for locale support in CMake
1 parent d8cd848 commit 1839f2d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/lib_json/CMakeLists.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,34 @@ if( CMAKE_COMPILER_IS_GNUCXX )
99
endif()
1010
endif( CMAKE_COMPILER_IS_GNUCXX )
1111

12+
include(CheckIncludeFileCXX)
13+
include(CheckTypeSize)
14+
include(CheckStructHasMember)
15+
include(CheckCXXSymbolExists)
16+
17+
check_include_file_cxx(clocale HAVE_CLOCALE)
18+
check_cxx_symbol_exists(localeconv clocale HAVE_LOCALECONV)
19+
20+
if(CMAKE_VERSION VERSION_LESS 3.0.0)
21+
# The "LANGUAGE CXX" parameter is not supported in CMake versions below 3,
22+
# so the C compiler and header has to be used.
23+
check_include_file(locale.h HAVE_LOCALE_H)
24+
set(CMAKE_EXTRA_INCLUDE_FILES locale.h)
25+
check_type_size("struct lconv" LCONV_SIZE)
26+
unset(CMAKE_EXTRA_INCLUDE_FILES)
27+
check_struct_has_member("struct lconv" decimal_point locale.h HAVE_DECIMAL_POINT)
28+
else()
29+
set(CMAKE_EXTRA_INCLUDE_FILES clocale)
30+
check_type_size(lconv LCONV_SIZE LANGUAGE CXX)
31+
unset(CMAKE_EXTRA_INCLUDE_FILES)
32+
check_struct_has_member(lconv decimal_point clocale HAVE_DECIMAL_POINT LANGUAGE CXX)
33+
endif()
34+
35+
if(NOT (HAVE_CLOCALE AND HAVE_LCONV_SIZE AND HAVE_DECIMAL_POINT AND HAVE_LOCALECONV))
36+
message(WARNING "Locale functionality is not supported")
37+
add_definitions(-DNO_LOCALE_SUPPORT)
38+
endif()
39+
1240
SET( JSONCPP_INCLUDE_DIR ../../include )
1341

1442
SET( PUBLIC_HEADERS

0 commit comments

Comments
 (0)