1a15ff47af3c284fcc014a41a57a45710c107c8a
[openwrt/staging/lynxis.git] / tools / cmake / patches / 130-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 @@ -471,6 +471,10 @@ if(CMAKE_USE_OPENSSL)
24 check_symbol_exists(RAND_status "${CURL_INCLUDES}" HAVE_RAND_STATUS)
25 check_symbol_exists(RAND_screen "${CURL_INCLUDES}" HAVE_RAND_SCREEN)
26 check_symbol_exists(RAND_egd "${CURL_INCLUDES}" HAVE_RAND_EGD)
27 + check_library_exists("rt" clock_gettime "" HAVE_LIBRT)
28 + if(HAVE_LIBRT)
29 + list(APPEND OPENSSL_LIBRARIES rt)
30 + endif()
31
32 # Optionally build with a specific CA cert bundle.
33 if(CURL_CA_BUNDLE)