XCode v8 introduced clock_gettime() for iOS v10. However, it is a weak symbol, which means when earlier iOS versions try to use clock_gettime() it results in a crash due to the missing symbol. Detect this condition and do not set HAVE_CLOCK_GETTIME_MONOTONIC.

pull/64/head
Brad House 8 years ago
parent e4fe33edb7
commit 7518c26d8e
  1. 20
      CMakeLists.txt

@ -64,6 +64,18 @@ return 0;
}
"
IOS)
CHECK_C_SOURCE_COMPILES ("
#include <stdio.h>
#include <TargetConditionals.h>
int main() {
#if TARGET_OS_IPHONE == 0 || __IPHONE_OS_VERSION_MIN_REQUIRED < 100000
#error Not iOS v10
#endif
return 0;
}
"
IOS_V10)
ENDIF ()
IF (IOS AND HAVE_LIBRESOLV)
@ -236,7 +248,13 @@ CHECK_SYMBOL_EXISTS (SIOCGIFADDR "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_IOCTL_S
CHECK_SYMBOL_EXISTS (MSG_NOSIGNAL "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_MSG_NOSIGNAL)
CHECK_SYMBOL_EXISTS (PF_INET6 "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_PF_INET6)
CHECK_SYMBOL_EXISTS (SO_NONBLOCK "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_SO_NONBLOCK)
CHECK_SYMBOL_EXISTS (CLOCK_MONOTONIC "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_CLOCK_GETTIME_MONOTONIC)
# XCode v8 bug: iOS when targeting less than v10 will say clock_gettime exists, it is a weak
# symbol that only exists in iOS10 and will cause a crash at runtime when running on versions
# less than 10. Skip finding CLOCK_MONOTONIC on iOS target < 10.
IF ((NOT IOS) OR IOS_V10)
CHECK_SYMBOL_EXISTS (CLOCK_MONOTONIC "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_CLOCK_GETTIME_MONOTONIC)
ENDIF ()
CHECK_STRUCT_HAS_MEMBER("struct sockaddr_in6" sin6_scope_id "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID LANGUAGE C)

Loading…
Cancel
Save