This is an automated email from the ASF dual-hosted git repository.
xyz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pulsar-client-cpp.git
The following commit(s) were added to refs/heads/main by this push:
new d3fd6b2 Make it optional to link statically to libgcc and libstdc++
(#474)
d3fd6b2 is described below
commit d3fd6b2afa2c8ca0df77d60c8e5b9169a0e081ce
Author: Yunze Xu <[email protected]>
AuthorDate: Sat Feb 8 17:41:46 2025 +0800
Make it optional to link statically to libgcc and libstdc++ (#474)
---
lib/CMakeLists.txt | 3 ++-
pkg/deb/build-deb.sh | 2 +-
pkg/rpm/SPECS/pulsar-client.spec | 1 +
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index f578c29..21b308c 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -76,6 +76,7 @@ target_include_directories(PULSAR_OBJECT_LIB PUBLIC
"${CMAKE_SOURCE_DIR}/include"
"${CMAKE_BINARY_DIR}/include")
+option(LINK_STATIC_GCC_CXX "Link statically to libgcc and libstdc++" OFF)
include(CheckCXXSymbolExists)
if (BUILD_DYNAMIC_LIB)
add_library(pulsarShared SHARED $<TARGET_OBJECTS:PULSAR_OBJECT_LIB>)
@@ -94,7 +95,7 @@ if (BUILD_DYNAMIC_LIB)
target_link_options(pulsarShared PRIVATE -Wl,-Bsymbolic)
endif ()
check_cxx_symbol_exists(__GLIBCXX__ iostream GLIBCXX)
- if (GLIBCXX)
+ if (GLIBCXX AND LINK_STATIC_GCC_CXX)
target_link_libraries(pulsarShared PUBLIC -static-libgcc
-static-libstdc++)
endif ()
endif()
diff --git a/pkg/deb/build-deb.sh b/pkg/deb/build-deb.sh
index 8415056..1dabb9f 100755
--- a/pkg/deb/build-deb.sh
+++ b/pkg/deb/build-deb.sh
@@ -41,7 +41,7 @@ pushd $CPP_DIR
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
chmod +x $(find . -name "*.sh")
-cmake . -DBUILD_TESTS=OFF -DBUILD_PERF_TOOLS=OFF -DLINK_STATIC=ON
+cmake . -DBUILD_TESTS=OFF -DBUILD_PERF_TOOLS=OFF -DLINK_STATIC=ON
-DLINK_STATIC_GCC_CXX=ON
make -j 3
popd
diff --git a/pkg/rpm/SPECS/pulsar-client.spec b/pkg/rpm/SPECS/pulsar-client.spec
index 425eec5..41a2e58 100644
--- a/pkg/rpm/SPECS/pulsar-client.spec
+++ b/pkg/rpm/SPECS/pulsar-client.spec
@@ -55,6 +55,7 @@ static library.
%build
git clone https://github.com/microsoft/vcpkg.git
cmake -B build -DINTEGRATE_VCPKG=ON -DCMAKE_BUILD_TYPE=Release \
+ -DLINK_STATIC_GCC_CXX=ON \
-DBUILD_TESTS=OFF -DBUILD_DYNAMIC_LIB=ON -DBUILD_STATIC_LIB=ON
cmake --build build -j8
./build-support/merge_archives_vcpkg.sh $PWD/build