Tarantool development patches archive
 help / color / mirror / Atom feed
From: Alexander Turenko <alexander.turenko@tarantool.org>
To: Kirill Yukhin <kyukhin@tarantool.org>
Cc: Alexander Turenko <alexander.turenko@tarantool.org>,
	tarantool-patches@freelists.org
Subject: [tarantool-patches] [PATCH 3/3] Make libdl.so optional (for FreeBSD prior to 11.2)
Date: Sat,  3 Nov 2018 07:29:34 +0300	[thread overview]
Message-ID: <e6fd17208e49c9ae7051defe3c36087102647ec3.1541219191.git.alexander.turenko@tarantool.org> (raw)
In-Reply-To: <cover.1541219191.git.alexander.turenko@tarantool.org>

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

  parent reply	other threads:[~2018-11-03  4:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-03  4:29 [tarantool-patches] [PATCH 0/3] Fix FreeBSD build Alexander Turenko
2018-11-03  4:29 ` [tarantool-patches] [PATCH 1/3] Update README.FreeBSD Alexander Turenko
2018-11-03  4:29 ` [tarantool-patches] [PATCH 2/3] Add <netinet/in.h> include on FreeBSD Alexander Turenko
2018-11-03  4:29 ` Alexander Turenko [this message]
2018-11-03  6:23 ` [tarantool-patches] [PATCH 0/3] Fix FreeBSD build Vladimir Davydov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e6fd17208e49c9ae7051defe3c36087102647ec3.1541219191.git.alexander.turenko@tarantool.org \
    --to=alexander.turenko@tarantool.org \
    --cc=kyukhin@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH 3/3] Make libdl.so optional (for FreeBSD prior to 11.2)' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox