File add-soversion-option.patch of Package boringssl
From e23b950bc30e196937861b7b167a5f520c8b2118 Mon Sep 17 00:00:00 2001
From: Michal Rostecki <mrostecki@suse.de>
Date: Tue, 6 Nov 2018 20:29:25 +0100
Subject: [PATCH] cmake: Add SOVERSION option
The SOVERSION option allows to version the shared library. Version
defined there is 0 and the versioned library files have extension
`so.0`. Optional soversion is helpful for packaging and making a
difference between `lib*` package (which contains `.so.0` file)
and `*-devel` package (which contains `.so` file).
Change-Id: If52a0657de0f524a2c40cb51a6e9c36aac87024d
---
BUILDING.md | 3 +++
CMakeLists.txt | 8 ++++++++
crypto/CMakeLists.txt | 6 ++++++
decrepit/CMakeLists.txt | 6 ++++++
ssl/CMakeLists.txt | 6 ++++++
5 files changed, 29 insertions(+)
diff --git a/BUILDING.md b/BUILDING.md
index 924f6c924..69cecefc4 100644
--- a/BUILDING.md
+++ b/BUILDING.md
@@ -71,6 +71,9 @@ Windows, where functions need to be tagged with `dllimport` when coming from a
shared library, define `BORINGSSL_SHARED_LIBRARY` in any code which `#include`s
the BoringSSL headers.
+If you want to build a shared library with versioned `.so` files (`.so.0`), pass
+`-DSOVERSION=1`.
+
In order to serve environments where code-size is important as well as those
where performance is the overriding concern, `OPENSSL_SMALL` can be defined to
remove some code that is especially large.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1f18782f3..b8ea82c08 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,7 @@
cmake_minimum_required(VERSION 2.8.11)
+set(boringssl_SOVERSION 0)
+
# Report AppleClang separately from Clang. Their version numbers are different.
# https://cmake.org/cmake/help/v3.0/policy/CMP0025.html
if(POLICY CMP0025)
@@ -503,6 +505,12 @@ endif()
# Add minimal googletest targets. The provided one has many side-effects, and
# googletest has a very straightforward build.
add_library(boringssl_gtest third_party/googletest/src/gtest-all.cc)
+if(BUILD_SHARED_LIBS AND SOVERSION)
+ set_target_properties(
+ boringssl_gtest PROPERTIES
+ SOVERSION ${boringssl_SOVERSION}
+ )
+endif()
target_include_directories(boringssl_gtest PRIVATE third_party/googletest)
include_directories(third_party/googletest/include)
diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt
index 863591020..31e1c2b96 100644
--- a/crypto/CMakeLists.txt
+++ b/crypto/CMakeLists.txt
@@ -404,6 +404,12 @@ add_library(
${CRYPTO_ARCH_SOURCES}
${CRYPTO_FIPS_OBJECTS}
)
+if(BUILD_SHARED_LIBS AND SOVERSION)
+ set_target_properties(
+ crypto PROPERTIES
+ SOVERSION ${boringssl_SOVERSION}
+ )
+endif()
add_dependencies(crypto global_target)
diff --git a/decrepit/CMakeLists.txt b/decrepit/CMakeLists.txt
index 1cb5e11f7..26d1a6dc9 100644
--- a/decrepit/CMakeLists.txt
+++ b/decrepit/CMakeLists.txt
@@ -21,6 +21,12 @@ add_library(
x509/x509_decrepit.c
xts/xts.c
)
+if(BUILD_SHARED_LIBS AND SOVERSION)
+ set_target_properties(
+ decrepit PROPERTIES
+ SOVERSION ${boringssl_SOVERSION}
+ )
+endif()
add_dependencies(decrepit global_target)
diff --git a/ssl/CMakeLists.txt b/ssl/CMakeLists.txt
index d6c1294f1..102e015fd 100644
--- a/ssl/CMakeLists.txt
+++ b/ssl/CMakeLists.txt
@@ -40,6 +40,12 @@ add_library(
tls13_enc.cc
tls13_server.cc
)
+if(BUILD_SHARED_LIBS AND SOVERSION)
+ set_target_properties(
+ ssl PROPERTIES
+ SOVERSION ${boringssl_SOVERSION}
+ )
+endif()
add_dependencies(ssl global_target)
--
2.21.0