From 507c1eec51b51f09d922b76e088f89fbb66b6161 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Wed, 28 Jan 2015 00:50:21 -0500 Subject: [PATCH] Honor the standard BUILD_SHARED_LIBS cmake variable. The variable switches the default type for add_library from STATIC to SHARED. We can condition additional stuff on that for convenience. (tabtest still doesn't build.) BoringSSL as any kind of stable system shared library is still very much unsupported, but this is probably handy for making sure we don't forget all those pesky OPENSSL_EXPORTs. Change-Id: I66ab80bcddbf3724e03e85384141fdf4f4acbc2e Reviewed-on: https://boringssl-review.googlesource.com/3092 Reviewed-by: Adam Langley --- BUILDING | 12 +++++------- CMakeLists.txt | 7 +++++++ crypto/CMakeLists.txt | 1 - ssl/CMakeLists.txt | 1 - 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/BUILDING b/BUILDING index 830f58b2..18ddde17 100644 --- a/BUILDING +++ b/BUILDING @@ -40,7 +40,7 @@ You usually don't need to run cmake again after changing CMakeLists.txt files because the build scripts will detect changes to them and rebuild themselves automatically. -Note that the default build flags in the top-leve CMakeLists.txt are for +Note that the default build flags in the top-level CMakeLists.txt are for debugging - optimisation isn't enabled. If you want to cross-compile then there are example toolchain files for 32-bit @@ -49,12 +49,10 @@ like this: cmake -DCMAKE_TOOLCHAIN_FILE=../util/arm-toolchain.cmake -GNinja .. -If you want to build as a shared library you need to tweak the STATIC tags in -the CMakeLists.txts and also define BORINGSSL_SHARED_LIBRARY and -BORINGSSL_IMPLEMENTATION. On Windows, where functions need to be tagged with -"dllimport" when coming from a shared library, you need just -BORINGSSL_SHARED_LIBRARY defined in the code which #includes the BoringSSL -headers. +If you want to build as a shared library, pass -DBUILD_SHARED_LIBS=1. On +Windows, where functions need to be tagged with "dllimport" when coming from a +shared library, define BORINGSSL_SHARED_LIBRARY in any code which #includes the +BoringSSL headers. Known Limitations on Windows: diff --git a/CMakeLists.txt b/CMakeLists.txt index 199d44da..6d2c39ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,13 @@ endif() add_definitions(-DBORINGSSL_IMPLEMENTATION) +if (BUILD_SHARED_LIBS) + add_definitions(-DBORINGSSL_SHARED_LIBRARY) + # Enable position-independent code globally. This is needed because + # some library targets are OBJECT libraries. + set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) +endif() + if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64") set(ARCH "x86_64") elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "amd64") diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt index 6fa0a268..691f79e9 100644 --- a/crypto/CMakeLists.txt +++ b/crypto/CMakeLists.txt @@ -134,7 +134,6 @@ add_subdirectory(pkcs8) add_library( crypto - STATIC crypto.c crypto_error.c diff --git a/ssl/CMakeLists.txt b/ssl/CMakeLists.txt index 954418b0..a7292db5 100644 --- a/ssl/CMakeLists.txt +++ b/ssl/CMakeLists.txt @@ -4,7 +4,6 @@ add_subdirectory(pqueue) add_library( ssl - STATIC d1_both.c d1_clnt.c