From 5da33e2da710b8b10d6cb8f6bd39341e1c16f25e Mon Sep 17 00:00:00 2001 From: Casey Waldren Date: Fri, 3 Nov 2023 16:11:03 -0700 Subject: [PATCH] how about linking boost dynamically? --- CMakeLists.txt | 9 ++++++--- libs/client-sdk/src/boost.cpp | 5 ----- libs/server-sdk/src/CMakeLists.txt | 1 - libs/server-sdk/src/boost.cpp | 5 ----- 4 files changed, 6 insertions(+), 14 deletions(-) delete mode 100644 libs/client-sdk/src/boost.cpp delete mode 100644 libs/server-sdk/src/boost.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index e9f9e29b0..af05b7e9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -105,15 +105,18 @@ endif () find_package(OpenSSL REQUIRED) message(STATUS "LaunchDarkly: using OpenSSL v${OPENSSL_VERSION}") -# Even though the main SDK might be a static or shared lib, boost should always statically -# linked into the binary. -set(Boost_USE_STATIC_LIBS ON) if (LD_BUILD_SHARED_LIBS) # When building a shared library we hide all symbols # aside from this we have specifically exported for the C-API. set(CMAKE_CXX_VISIBILITY_PRESET hidden) set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) +else () + # If the SDK is being compiled as a static library, link boost in statically so that there's only + # one artifact. Otherwise if the SDK is a dynamic library, then link in boost dynamically because: + # - Boost is compiled without fpic, so we can't link it into our shared lib unless we compile it separately with fpic + # - If the user wants shared libraries, then they probably want to link boost's shared libraries too. + set(Boost_USE_STATIC_LIBS ON) endif () set(Boost_USE_MULTITHREADED ON) diff --git a/libs/client-sdk/src/boost.cpp b/libs/client-sdk/src/boost.cpp deleted file mode 100644 index 5c9ea02b1..000000000 --- a/libs/client-sdk/src/boost.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// This file is used to include boost url/json when building a shared library on linux/mac. -// Windows links static libs in this case and does not include these src files, as there -// are issues compiling the value.ipp file from JSON with MSVC. -#include -#include diff --git a/libs/server-sdk/src/CMakeLists.txt b/libs/server-sdk/src/CMakeLists.txt index d6e2b93aa..5a6cd4fe0 100644 --- a/libs/server-sdk/src/CMakeLists.txt +++ b/libs/server-sdk/src/CMakeLists.txt @@ -16,7 +16,6 @@ endif () target_sources(${LIBNAME} PRIVATE ${HEADER_LIST} - boost.cpp client.cpp client_impl.cpp config/config.cpp diff --git a/libs/server-sdk/src/boost.cpp b/libs/server-sdk/src/boost.cpp deleted file mode 100644 index cf3d204d2..000000000 --- a/libs/server-sdk/src/boost.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// This file is used to include boost json when building a shared library on -// linux/mac. Windows links static libs in this case and does not include these -// src files, as there are issues compiling the value.ipp file from JSON with -// MSVC. -#include