Skip to content

Commit 5a87137

Browse files
committed
fix compiling with non-glib Linux c libraries
This commit fixes building against uclibc and musl c libraries. - musl requires sys/time.h - musl and uclibc don't define __GLIBC__, and don't include xlocal.h. Instead of adding more define checks, have cmake check for the header and set the define "HAVE_XLOCALE_H", then check for that instead.
1 parent 28919d0 commit 5a87137

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Release/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ include(cmake/cpprest_find_boost.cmake)
4242
include(cmake/cpprest_find_zlib.cmake)
4343
include(cmake/cpprest_find_openssl.cmake)
4444
include(cmake/cpprest_find_websocketpp.cmake)
45+
include(CheckIncludeFiles)
4546

4647
find_package(Threads REQUIRED)
4748
if(THREADS_HAVE_PTHREAD_ARG)
@@ -56,6 +57,7 @@ if(CPPREST_EXCLUDE_WEBSOCKETS)
5657
set(CPPREST_WEBSOCKETS_IMPL none CACHE STRING "Internal use.")
5758
endif()
5859

60+
CHECK_INCLUDE_FILES(xlocale.h HAVE_XLOCALE_H)
5961
if(APPLE) # Note: also iOS
6062
set(CPPREST_PPLX_IMPL apple CACHE STRING "Internal use.")
6163
set(CPPREST_WEBSOCKETS_IMPL wspp CACHE STRING "Internal use.")

Release/include/cpprest/asyncrt_utils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@
1919
#include <system_error>
2020
#include <random>
2121
#include <locale.h>
22-
2322
#include "pplx/pplxtasks.h"
2423
#include "cpprest/details/basic_types.h"
2524

2625
#if !defined(_WIN32) || (_MSC_VER >= 1700)
26+
#include <sys/time.h>
2727
#include <chrono>
2828
#endif
2929

3030
#ifndef _WIN32
3131
#include <boost/algorithm/string.hpp>
32-
#if !defined(ANDROID) && !defined(__ANDROID__) && !defined(__GLIBC__) // CodePlex 269
32+
#if !defined(ANDROID) && !defined(__ANDROID__) && defined(HAVE_XLOCALE_H) // CodePlex 269
3333
/* Systems using glibc: xlocale.h has been removed from glibc 2.26
3434
The above include of locale.h is sufficient
3535
Further details: https://sourceware.org/git/?p=glibc.git;a=commit;h=f0be25b6336db7492e47d2e8e72eb8af53b5506d */

0 commit comments

Comments
 (0)