From e7b3cd7ec1f287281b628cb22c2b5ce7ed8bb883 Mon Sep 17 00:00:00 2001 From: huangkaicheng Date: Thu, 23 Apr 2020 06:17:22 +0100 Subject: [PATCH] iOS: detect and avoid net/route.h LWS builds OK on iOS SDK as unix type plat, except it doesn't have net/route.h. Detect we're building on iOS at CMake and export a preprocessor define we can use to snip out the missing include. --- CMakeLists.txt | 4 ++++ cmake/lws_config.h.in | 1 + lib/plat/unix/unix-sockets.c | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index dde6223e8..a41a9c747 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -177,6 +177,10 @@ option(LWS_WITH_FSMOUNT "Overlayfs and fallback mounting apis" OFF) # End of user settings # +if(IOS) + set(LWS_DETECTED_PLAT_IOS 1) +endif() + # Workaround for ESP-IDF # Detect ESP_PLATFORM environment flag, if exist, set LWS_WITH_ESP32. # Otherwise the user may not be able to run configuration ESP-IDF in the first time. diff --git a/cmake/lws_config.h.in b/cmake/lws_config.h.in index ecfd8f4d2..131648f67 100644 --- a/cmake/lws_config.h.in +++ b/cmake/lws_config.h.in @@ -22,6 +22,7 @@ #cmakedefine LWS_BUILD_HASH "${LWS_BUILD_HASH}" #cmakedefine LWS_BUILTIN_GETIFADDRS #cmakedefine LWS_CLIENT_HTTP_PROXYING +#cmakedefine LWS_DETECTED_PLAT_IOS #cmakedefine LWS_FALLBACK_GETHOSTBYNAME #cmakedefine LWS_HAS_INTPTR_T #cmakedefine LWS_HAS_GETOPT_LONG diff --git a/lib/plat/unix/unix-sockets.c b/lib/plat/unix/unix-sockets.c index 5e7a68ac2..3dd4ae38a 100644 --- a/lib/plat/unix/unix-sockets.c +++ b/lib/plat/unix/unix-sockets.c @@ -28,7 +28,11 @@ #include "private-lib-core.h" #include + +#if !defined(LWS_DETECTED_PLAT_IOS) #include +#endif + #include #include