tools/cmake: Update to 3.12.0
[openwrt/staging/wigyori.git] / tools / cmake / patches / 120-curl-fix-libressl-linking.patch
1 From: Jo-Philipp Wich <jo@mein.io>
2 Date: Wed, 11 Jan 2017 03:36:04 +0100
3 Subject: [PATCH] cmcurl: link librt
4
5 When cmake is linked against LibreSSL, there might be an indirect
6 dependency on librt on certain systems if LibreSSL's libcrypto uses
7 clock_gettime() from librt:
8
9 [ 28%] Linking C executable LIBCURL
10 .../lib/libcrypto.a(getentropy_linux.o): In function `getentropy_fallback':
11 getentropy_linux.c:(.text+0x16d): undefined reference to `clock_gettime'
12 getentropy_linux.c:(.text+0x412): undefined reference to `clock_gettime'
13 collect2: error: ld returned 1 exit status
14 make[5]: *** [Utilities/cmcurl/LIBCURL] Error 1
15
16 Modify the cmcurl CMakeLists.txt to check for clock_gettime() in librt
17 and unconditionally link the rt library when the symbol is found.
18
19 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
20 ---
21 --- a/Utilities/cmcurl/CMakeLists.txt
22 +++ b/Utilities/cmcurl/CMakeLists.txt
23 @@ -452,6 +452,14 @@ if(CMAKE_USE_OPENSSL)
24 set(USE_OPENSSL ON)
25 set(HAVE_LIBCRYPTO ON)
26 set(HAVE_LIBSSL ON)
27 + check_library_exists("rt" clock_gettime "" HAVE_LIBRT)
28 + if(HAVE_LIBRT)
29 + list(APPEND OPENSSL_LIBRARIES rt)
30 + endif()
31 + check_library_exists("pthread" pthread_once "" HAVE_PTHREAD)
32 + if(HAVE_PTHREAD)
33 + list(APPEND OPENSSL_LIBRARIES pthread)
34 + endif()
35 list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES})
36 include_directories(${OPENSSL_INCLUDE_DIR})
37 set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})