base-files: create /etc/config/ directory
[openwrt/staging/wigyori.git] / tools / cmake / patches / 140-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 --- a/Utilities/cmcurl/CMakeLists.txt
21 +++ b/Utilities/cmcurl/CMakeLists.txt
22 @@ -374,6 +374,10 @@ set(HAVE_LIBSSL OFF)
23 if(CMAKE_USE_OPENSSL)
24 find_package(OpenSSL)
25 if(OPENSSL_FOUND)
26 + check_library_exists("rt" clock_gettime "" HAVE_LIBRT)
27 + if(HAVE_LIBRT)
28 + list(APPEND OPENSSL_LIBRARIES rt)
29 + endif()
30 list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES})
31 set(USE_OPENSSL ON)
32 set(HAVE_LIBCRYPTO ON)