diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d9e7930c..99315890f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -148,6 +148,7 @@ option(ENABLE_CODE_COVERAGE "Enable code coverage reporting" OFF) option(ENABLE_MONOTONIC_CLOCK "Enforced clock_gettime with monotonic clock on GC CV" ${ENABLE_MONOTONIC_CLOCK_DEFAULT}) option(ENABLE_STDCXX_SYNC "Use C++11 chrono and threads for timing instead of pthreads" ${ENABLE_STDCXX_SYNC_DEFAULT}) option(USE_OPENSSL_PC "Use pkg-config to find OpenSSL libraries" ON) +option(OPENSSL_USE_STATIC_LIBS "Link OpenSSL libraries statically." OFF) option(USE_BUSY_WAITING "Enable more accurate sending times at a cost of potentially higher CPU load" OFF) option(USE_GNUSTL "Get c++ library/headers from the gnustl.pc" OFF) option(ENABLE_SOCK_CLOEXEC "Enable setting SOCK_CLOEXEC on a socket" ON) @@ -345,6 +346,10 @@ if (ENABLE_ENCRYPTION) # fall back to find_package method otherwise if (USE_OPENSSL_PC) pkg_check_modules(SSL ${SSL_REQUIRED_MODULES}) + if (OPENSSL_USE_STATIC_LIBS) + # use `pkg-config --static xxx` found libs + set(SSL_LIBRARIES ${SSL_STATIC_LIBRARIES}) + endif() endif() if (SSL_FOUND) # We have some cases when pkg-config is improperly configured diff --git a/configure-data.tcl b/configure-data.tcl index d4c75f05b..eace99da1 100644 --- a/configure-data.tcl +++ b/configure-data.tcl @@ -57,6 +57,7 @@ set cmake_options { enable-thread-check "Enable #include that implements THREAD_* macros" enable-stdc++-sync "Use standard C++11 chrono/threads instead of pthread wrapper (default: OFF, on Windows: ON)" use-openssl-pc "Use pkg-config to find OpenSSL libraries (default: ON)" + openssl-use-static-libs "Link OpenSSL statically (default: OFF)." use-busy-waiting "Enable more accurate sending times at a cost of potentially higher CPU load (default: OFF)" use-gnustl "Get c++ library/headers from the gnustl.pc" enable-sock-cloexec "Enable setting SOCK_CLOEXEC on a socket (default: ON)" diff --git a/docs/build/build-options.md b/docs/build/build-options.md index b3a50ce13..8c87229c9 100644 --- a/docs/build/build-options.md +++ b/docs/build/build-options.md @@ -61,6 +61,7 @@ Option details are given further below. | [`USE_ENCLIB`](#use_enclib) | 1.3.3 | `STRING` | openssl | Encryption library to be used (`openssl`, `gnutls`, `mbedtls`). | | [`USE_GNUSTL`](#use_gnustl) | 1.3.4 | `BOOL` | OFF | Use `pkg-config` with the `gnustl` package name to extract the header and library path for the C++ standard library. | | [`USE_OPENSSL_PC`](#use_openssl_pc) | 1.3.0 | `BOOL` | ON | Use `pkg-config` to find OpenSSL libraries. | +| [`OPENSSL_USE_STATIC_LIBS`](#openssl_use_static_libs) | 1.5.0 | `BOOL` | OFF | Link OpenSSL statically. | | [`USE_STATIC_LIBSTDCXX`](#use_static_libstdcxx) | 1.2.0 | `BOOL` | OFF | Enforces linking the SRT library against the static libstdc++ library. | | [`WITH_COMPILER_PREFIX`](#with_compiler_prefix) | 1.3.0 | `STRING` | OFF | Sets C/C++ toolchains as `` and ``, overriding the default compiler. | | [`WITH_COMPILER_TYPE`](#with_compiler_type) | 1.3.0 | `STRING` | OFF | Sets the compiler type to be used (values: gcc, cc, clang, etc.). | @@ -551,6 +552,12 @@ built-in one). When ON, uses `pkg-config` to find OpenSSL libraries. You can turn this OFF to force `cmake` to find OpenSSL by its own preferred method. +### OPENSSL_USE_STATIC_LIBS +**`--openssl-use-static-libs`** (default: OFF) + +When ON, OpenSSL libraries are linked statically. +When `pkg-config`(`-DUSE_OPENSSL_PC=ON`) is used, static OpenSSL libraries are listed in `SSL_STATIC_LIBRARIES`. See `_STATIC` in [CMake's FindPkgConfig](https://cmake.org/cmake/help/latest/module/FindPkgConfig.html). +On Windows additionally links `crypt32.lib`. #### USE_STATIC_LIBSTDCXX **`--use-static-libstdc++`** (default: OFF) diff --git a/scripts/ShowProjectConfig.cmake b/scripts/ShowProjectConfig.cmake index c26a5e95a..9cb959294 100644 --- a/scripts/ShowProjectConfig.cmake +++ b/scripts/ShowProjectConfig.cmake @@ -165,6 +165,7 @@ function(ShowProjectConfig) " ENABLE_MONOTONIC_CLOCK: ${ENABLE_MONOTONIC_CLOCK}\n" " ENABLE_STDCXX_SYNC: ${ENABLE_STDCXX_SYNC}\n" " USE_OPENSSL_PC: ${USE_OPENSSL_PC}\n" + " OPENSSL_USE_STATIC_LIBS: ${OPENSSL_USE_STATIC_LIBS}\n" " USE_BUSY_WAITING: ${USE_BUSY_WAITING}\n" " USE_GNUSTL: ${USE_GNUSTL}\n" " ENABLE_SOCK_CLOEXEC: ${ENABLE_SOCK_CLOEXEC}\n" diff --git a/scripts/build-android/mksrt b/scripts/build-android/mksrt index b2e176046..a36900768 100755 --- a/scripts/build-android/mksrt +++ b/scripts/build-android/mksrt @@ -17,7 +17,7 @@ done cd $SRC_DIR ./configure --use-enclib=$ENC_LIB \ ---use-openssl-pc=OFF --OPENSSL_USE_STATIC_LIBS=TRUE \ +--use-openssl-pc=OFF \ --OPENSSL_INCLUDE_DIR=$INSTALL_DIR/include \ --OPENSSL_CRYPTO_LIBRARY=$INSTALL_DIR/lib/libcrypto.a --OPENSSL_SSL_LIBRARY=$INSTALL_DIR/lib/libssl.a \ --STATIC_MBEDTLS=FALSE \