[tarantool-patches] [PATCH 3/3] Make libdl.so optional (for FreeBSD prior to 11.2)
Alexander Turenko
alexander.turenko at tarantool.org
Sat Nov 3 07:29:34 MSK 2018
FreeBSD 10.4 has no libdl.so.
Fixes #3750.
---
cmake/FindCURL.cmake | 21 +++++++++++++++++----
src/CMakeLists.txt | 9 ++++++++-
2 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/cmake/FindCURL.cmake b/cmake/FindCURL.cmake
index e2e2c6f20..e13b6cde4 100644
--- a/cmake/FindCURL.cmake
+++ b/cmake/FindCURL.cmake
@@ -24,9 +24,15 @@ else()
set(NGHTTP2_LIB_NAME nghttp2)
endif()
-# Curl may require nghttp library, search for it and add to dependicies if
-# found
+# Always links pthread and dl dynamically.
+set(PTHREAD_LIB_NAME pthread)
+set(DL_LIB_NAME dl)
+
+# Curl may be linked with optional or target-dependent libraries,
+# search for them and add to dependicies if found.
find_library(NGHTTP2_LIBRARY NAMES ${NGHTTP2_LIB_NAME})
+find_library(PTHREAD_LIBRARY NAMES ${PTHREAD_LIB_NAME})
+find_library(DL_LIBRARY NAMES ${DL_LIB_NAME})
if(DEFINED CURL_ROOT)
set(CURL_FIND_OPTS NO_CMAKE NO_CMAKE_SYSTEM_PATH)
@@ -79,14 +85,21 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(CURL
if(CURL_FOUND)
set(CURL_LIBRARIES ${CURL_LIBRARY})
+ set(CURL_LIBRARIES ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES})
if(BUILD_STATIC)
- # in case of a static build we have to add curl dependencies
+ # In case of a static build we have to add curl dependencies.
if(NOT "${NGHTTP2_LIBRARY}" STREQUAL "NGHTTP2_LIBRARY-NOTFOUND")
set(CURL_LIBRARIES ${CURL_LIBRARIES} ${NGHTTP2_LIBRARY})
endif()
+ if(NOT "${PTHREAD_LIBRARY}" STREQUAL "PTHREAD_LIBRARY-NOTFOUND")
+ set(CURL_LIBRARIES ${CURL_LIBRARIES} ${PTHREAD_LIBRARY})
+ endif()
+ if(NOT "${DL_LIBRARY}" STREQUAL "DL_LIBRARY-NOTFOUND")
+ set(CURL_LIBRARIES ${CURL_LIBRARIES} ${DL_LIBRARY})
+ endif()
endif()
set(CURL_INCLUDE_DIRS ${CURL_INCLUDE_DIR})
- set(CMAKE_REQUIRED_LIBRARIES ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES} pthread dl)
+ set(CMAKE_REQUIRED_LIBRARIES ${CURL_LIBRARIES})
set(CMAKE_REQUIRED_INCLUDES ${CURL_INCLUDE_DIRS})
check_c_source_runs("
#include <curl/curl.h>
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d296348a3..ceff96ec0 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -67,7 +67,14 @@ add_custom_target(ragel
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMAND ragel -G2 src/uri.rl -o src/uri.c)
-set (generic_libraries pthread dl)
+# There is no libdl.so on FreeBSD prior to 11.2.
+#
+# Always links pthread and dl dynamically.
+set(generic_libraries pthread)
+find_library(DL_LIBRARY NAMES dl)
+if(NOT "${DL_LIBRARY}" STREQUAL "DL_LIBRARY-NOTFOUND")
+ set(generic_libraries ${generic_libraries} dl)
+endif()
set (core_sources
diag.c
--
2.19.1
More information about the Tarantool-patches
mailing list