Tarantool development patches archive
 help / color / mirror / Atom feed
From: "Alexander V. Tikhonov" <avtikhon@tarantool.org>
To: Oleg Piskunov <o.piskunov@tarantool.org>,
	Sergey Bronnikov <sergeyb@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org,
	Alexander Turenko <alexander.turenko@tarantool.org>
Subject: [Tarantool-patches] [PATCH v2 3/7] build: enable cmake in curl build
Date: Tue, 26 May 2020 17:42:34 +0300	[thread overview]
Message-ID: <97dd88360f3a02c3e48e22b41be68a2d305790ad.1590503508.git.avtikhon@tarantool.org> (raw)
In-Reply-To: <cover.1590503508.git.avtikhon@tarantool.org>
In-Reply-To: <cover.1590503508.git.avtikhon@tarantool.org>

Changed autoconf tools in Curl build to cmake use for builds where
cmake major starts from 3. It was made so because cmake in curl
build works only with 3.0 version and above, the following issue
found on:
  CentOS 6,7
  Ubuntu 14.04

Issue with curl cmake based build with cmake before 3.0 version:
  CMake Error at CMakeLists.txt:41 (cmake_minimum_required):
    CMake 3.0 or higher is required.  You are running version 2.8.12.2

For curl cmake buld all autoconf options were ported to cmake
configuration call.

Also found that CURL cmake configuration file:
  third_party/curl/lib/CMakeLists.txt

has installation part for built libcurl.a library:
  install(TARGETS ${LIB_NAME}
    EXPORT ${TARGETS_EXPORT_NAME}
    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}

where it changes CMAKE_INSTALL_LIBDIR to appropriate name with
suffix of the architecture, like:
  lib
  lib64
  x86_64

Found that find_library routine from the file:
  cmake/FindLibCURL.cmake

returns only 'lib' value and it breaks the building of the depends
binaries. To avoid of it the CMAKE_INSTALL_LIBDIR option was set to
cmake call:
  -DCMAKE_INSTALL_LIBDIR=lib

Part of #4968
---
 cmake/BuildLibCURL.cmake | 240 ++++++++++++++++++++++-----------------
 1 file changed, 138 insertions(+), 102 deletions(-)

diff --git a/cmake/BuildLibCURL.cmake b/cmake/BuildLibCURL.cmake
index 5f8b15a63..39566145e 100644
--- a/cmake/BuildLibCURL.cmake
+++ b/cmake/BuildLibCURL.cmake
@@ -25,10 +25,14 @@ macro(curl_build)
         set(ASYN_DNS_USED "ares")
         set(ASYN_DNS_UNUSED "threaded-resolver")
         set(ASYN_DNS_PATH "=${ARES_INSTALL_DIR}")
+        set(ENABLE_ARES "ON")
+        set(CMAKE_FIND_ROOT_PATH "${ARES_INSTALL_DIR}")
     else()
         set(ASYN_DNS_USED "threaded-resolver")
         set(ASYN_DNS_UNUSED "ares")
         set(ASYN_DNS_PATH "")
+        set(ENABLE_ARES "OFF")
+        set(CMAKE_FIND_ROOT_PATH "")
     endif()
 
     set(ENABLED_DNS_OPT "--enable-${ASYN_DNS_USED}${ASYN_DNS_PATH}")
@@ -49,108 +53,140 @@ macro(curl_build)
     endif()
 
     include(ExternalProject)
-    ExternalProject_Add(
-        bundled-libcurl-project
-        SOURCE_DIR ${LIBCURL_SOURCE_DIR}
-        PREFIX ${LIBCURL_INSTALL_DIR}
-        DOWNLOAD_DIR ${LIBCURL_BINARY_DIR}
-        TMP_DIR ${LIBCURL_BINARY_DIR}/tmp
-        STAMP_DIR ${LIBCURL_BINARY_DIR}/stamp
-        BINARY_DIR ${LIBCURL_BINARY_DIR}
-        CONFIGURE_COMMAND
-            cd <SOURCE_DIR> && ./buildconf &&
-            cd <BINARY_DIR> && <SOURCE_DIR>/configure
-                # Pass the same toolchain as is used to build
-                # tarantool itself, because they can be
-                # incompatible.
-                CC=${CMAKE_C_COMPILER}
-                LD=${CMAKE_LINKER}
-                AR=${CMAKE_AR}
-                RANLIB=${CMAKE_RANLIB}
-                NM=${CMAKE_NM}
-                STRIP=${CMAKE_STRIP}
-
-                # Pass -isysroot=<SDK_PATH> option on Mac OS, see
-                # above.
-                # Note: Passing of CPPFLAGS / CFLAGS explicitly
-                # discards using of corresponsing environment
-                # variables.
-                CPPFLAGS=${LIBCURL_CPPFLAGS}
-                CFLAGS=${LIBCURL_CFLAGS}
-
-                # Pass empty LDFLAGS to discard using of
-                # corresponding environment variable.
-                # It is possible that a linker flag assumes that
-                # some compilation flag is set. We don't pass
-                # CFLAGS from environment, so we should not do it
-                # for LDFLAGS too.
-                LDFLAGS=
-
-                --prefix <INSTALL_DIR>
-                --enable-static
-                --enable-shared
-
-                --with-zlib
-                ${LIBCURL_OPENSSL_OPT}
-                --with-ca-fallback
-
-                --without-brotli
-                --without-gnutls
-                --without-mbedtls
-                --without-cyassl
-                --without-wolfssl
-                --without-mesalink
-                --without-nss
-                --without-ca-bundle
-                --without-ca-path
-                --without-libpsl
-                --without-libmetalink
-                --without-librtmp
-                --without-winidn
-                --without-libidn2
-                --without-nghttp2
-                --without-ngtcp2
-                --without-nghttp3
-                --without-quiche
-                --without-zsh-functions-dir
-                --without-fish-functions-dir
-
-                ${ENABLED_DNS_OPT}
-                --enable-http
-                --enable-proxy
-                --enable-ipv6
-                --enable-unix-sockets
-                --enable-cookies
-                --enable-http-auth
-                --enable-mime
-                --enable-dateparse
-
-                ${DISABLED_DNS_OPT}
-                --disable-ftp
-                --disable-file
-                --disable-ldap
-                --disable-ldaps
-                --disable-rtsp
-                --disable-dict
-                --disable-telnet
-                --disable-tftp
-                --disable-pop3
-                --disable-imap
-                --disable-smb
-                --disable-smtp
-                --disable-gopher
-                --disable-manual
-                --disable-sspi
-                --disable-crypto-auth
-                --disable-ntlm-wb
-                --disable-tls-srp
-                --disable-doh
-                --disable-netrc
-                --disable-progress-meter
-                --disable-dnsshuffle
-                --disable-alt-svc
-        BUILD_COMMAND cd <BINARY_DIR> && $(MAKE)
-        INSTALL_COMMAND cd <BINARY_DIR> && $(MAKE) install)
+    if(${CMAKE_MAJOR_VERSION} VERSION_LESS "3")
+        ExternalProject_Add(
+            bundled-libcurl-project
+            SOURCE_DIR ${LIBCURL_SOURCE_DIR}
+            PREFIX ${LIBCURL_INSTALL_DIR}
+            DOWNLOAD_DIR ${LIBCURL_BINARY_DIR}
+            TMP_DIR ${LIBCURL_BINARY_DIR}/tmp
+            STAMP_DIR ${LIBCURL_BINARY_DIR}/stamp
+            BINARY_DIR ${LIBCURL_BINARY_DIR}
+            CONFIGURE_COMMAND
+                cd <SOURCE_DIR> && ./buildconf &&
+                cd <BINARY_DIR> && <SOURCE_DIR>/configure
+                    # Pass the same toolchain as is used to build
+                    # tarantool itself, because they can be
+                    # incompatible.
+                    CC=${CMAKE_C_COMPILER}
+                    LD=${CMAKE_LINKER}
+                    AR=${CMAKE_AR}
+                    RANLIB=${CMAKE_RANLIB}
+                    NM=${CMAKE_NM}
+                    STRIP=${CMAKE_STRIP}
+
+                    # Pass -isysroot=<SDK_PATH> option on Mac OS, see
+                    # above.
+                    # Note: Passing of CPPFLAGS / CFLAGS explicitly
+                    # discards using of corresponsing environment
+                    # variables.
+                    CPPFLAGS=${LIBCURL_CPPFLAGS}
+                    CFLAGS=${LIBCURL_CFLAGS}
+
+                    # Pass empty LDFLAGS to discard using of
+                    # corresponding environment variable.
+                    # It is possible that a linker flag assumes that
+                    # some compilation flag is set. We don't pass
+                    # CFLAGS from environment, so we should not do it
+                    # for LDFLAGS too.
+                    LDFLAGS=
+
+                    --prefix <INSTALL_DIR>
+                    --enable-static
+                    --enable-shared
+
+                    --with-zlib
+                    ${LIBCURL_OPENSSL_OPT}
+                    --with-ca-fallback
+
+                    --without-brotli
+                    --without-gnutls
+                    --without-mbedtls
+                    --without-cyassl
+                    --without-wolfssl
+                    --without-mesalink
+                    --without-nss
+                    --without-ca-bundle
+                    --without-ca-path
+                    --without-libpsl
+                    --without-libmetalink
+                    --without-librtmp
+                    --without-winidn
+                    --without-libidn2
+                    --without-nghttp2
+                    --without-ngtcp2
+                    --without-nghttp3
+                    --without-quiche
+                    --without-zsh-functions-dir
+                    --without-fish-functions-dir
+
+                    ${ENABLED_DNS_OPT}
+                    --enable-http
+                    --enable-proxy
+                    --enable-ipv6
+                    --enable-unix-sockets
+                    --enable-cookies
+                    --enable-http-auth
+                    --enable-mime
+                    --enable-dateparse
+
+                    ${DISABLED_DNS_OPT}
+                    --disable-ftp
+                    --disable-file
+                    --disable-ldap
+                    --disable-ldaps
+                    --disable-rtsp
+                    --disable-dict
+                    --disable-telnet
+                    --disable-tftp
+                    --disable-pop3
+                    --disable-imap
+                    --disable-smb
+                    --disable-smtp
+                    --disable-gopher
+                    --disable-manual
+                    --disable-sspi
+                    --disable-crypto-auth
+                    --disable-ntlm-wb
+                    --disable-tls-srp
+                    --disable-doh
+                    --disable-netrc
+                    --disable-progress-meter
+                    --disable-dnsshuffle
+                    --disable-alt-svc
+            BUILD_COMMAND cd <BINARY_DIR> && $(MAKE)
+            INSTALL_COMMAND cd <BINARY_DIR> && $(MAKE) install)
+    else()
+        ExternalProject_Add(
+            bundled-libcurl-project
+            SOURCE_DIR ${LIBCURL_SOURCE_DIR}
+            PREFIX ${LIBCURL_INSTALL_DIR}
+            DOWNLOAD_DIR ${LIBCURL_BINARY_DIR}
+            TMP_DIR ${LIBCURL_BINARY_DIR}/tmp
+            STAMP_DIR ${LIBCURL_BINARY_DIR}/stamp
+            BINARY_DIR ${LIBCURL_BINARY_DIR}/curl
+            CONFIGURE_COMMAND
+	        cd <BINARY_DIR> && cmake <SOURCE_DIR>
+                    -DCPPFLAGS=${LIBCURL_CPPFLAGS}
+                    -DCFLAGS=${LIBCURL_CFLAGS}
+                    -DLDFLAGS=
+                    -DCMAKE_INSTALL_LIBDIR=lib
+                    -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
+                    -DBUILD_TESTING=OFF
+                    -DCURL_STATICLIB=ON
+                    -DBUILD_SHARED_LIBS=OFF
+                    -DCMAKE_USE_OPENSSL=ON
+                    -DOPENSSL_ROOT_DIR=${FOUND_OPENSSL_ROOT_DIR}
+                    -DCURL_CA_FALLBACK=ON
+                    -DCMAKE_FIND_ROOT_PATH=${CMAKE_FIND_ROOT_PATH}
+                    -DENABLE_ARES=${ENABLE_ARES}
+                    -DHTTP_ONLY=ON
+                    -DCURL_DISABLE_SMB=ON
+                    -DCURL_DISABLE_GOPHER=ON
+                    -DCURL_DISABLE_CRYPTO_AUTH=ON
+            BUILD_COMMAND cd <BINARY_DIR> && $(MAKE) -j
+            INSTALL_COMMAND cd <BINARY_DIR> && $(MAKE) install)
+    endif()
 
     add_library(bundled-libcurl STATIC IMPORTED GLOBAL)
     set_target_properties(bundled-libcurl PROPERTIES IMPORTED_LOCATION
-- 
2.17.1

  parent reply	other threads:[~2020-05-26 14:42 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-26 14:42 [Tarantool-patches] [PATCH v2 0/7] Implement OOS build Alexander V. Tikhonov
2020-05-26 14:42 ` [Tarantool-patches] [PATCH v2 1/7] build: static build needs more cleanup in sources Alexander V. Tikhonov
2020-06-26 13:51   ` Alexander Turenko
2020-07-03 11:13   ` Kirill Yukhin
2020-05-26 14:42 ` [Tarantool-patches] [PATCH v2 2/7] build: fix static build w/ dockerfile with cmake Alexander V. Tikhonov
2020-05-26 14:42 ` Alexander V. Tikhonov [this message]
2020-05-26 14:42 ` [Tarantool-patches] [PATCH v2 4/7] Fix curl repository for out-of-source build Alexander V. Tikhonov
2020-05-26 14:42 ` [Tarantool-patches] [PATCH v2 5/7] build: change autoconf to cmake in curl build Alexander V. Tikhonov
2020-05-26 14:42 ` [Tarantool-patches] [PATCH v2 6/7] Skip failing test from out-of-source build Alexander V. Tikhonov
2020-05-26 14:42 ` [Tarantool-patches] [PATCH v2 7/7] gitlab-ci: add " Alexander V. Tikhonov

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=97dd88360f3a02c3e48e22b41be68a2d305790ad.1590503508.git.avtikhon@tarantool.org \
    --to=avtikhon@tarantool.org \
    --cc=alexander.turenko@tarantool.org \
    --cc=o.piskunov@tarantool.org \
    --cc=sergeyb@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v2 3/7] build: enable cmake in curl build' \
    /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