Skip to content

Commit d3fd6b2

Browse files
Make it optional to link statically to libgcc and libstdc++ (#474)
1 parent afeac78 commit d3fd6b2

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

lib/CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ target_include_directories(PULSAR_OBJECT_LIB PUBLIC
7676
"${CMAKE_SOURCE_DIR}/include"
7777
"${CMAKE_BINARY_DIR}/include")
7878

79+
option(LINK_STATIC_GCC_CXX "Link statically to libgcc and libstdc++" OFF)
7980
include(CheckCXXSymbolExists)
8081
if (BUILD_DYNAMIC_LIB)
8182
add_library(pulsarShared SHARED $<TARGET_OBJECTS:PULSAR_OBJECT_LIB>)
@@ -94,7 +95,7 @@ if (BUILD_DYNAMIC_LIB)
9495
target_link_options(pulsarShared PRIVATE -Wl,-Bsymbolic)
9596
endif ()
9697
check_cxx_symbol_exists(__GLIBCXX__ iostream GLIBCXX)
97-
if (GLIBCXX)
98+
if (GLIBCXX AND LINK_STATIC_GCC_CXX)
9899
target_link_libraries(pulsarShared PUBLIC -static-libgcc -static-libstdc++)
99100
endif ()
100101
endif()

pkg/deb/build-deb.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pushd $CPP_DIR
4141
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
4242

4343
chmod +x $(find . -name "*.sh")
44-
cmake . -DBUILD_TESTS=OFF -DBUILD_PERF_TOOLS=OFF -DLINK_STATIC=ON
44+
cmake . -DBUILD_TESTS=OFF -DBUILD_PERF_TOOLS=OFF -DLINK_STATIC=ON -DLINK_STATIC_GCC_CXX=ON
4545
make -j 3
4646
popd
4747

pkg/rpm/SPECS/pulsar-client.spec

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ static library.
5555
%build
5656
git clone https://github.com/microsoft/vcpkg.git
5757
cmake -B build -DINTEGRATE_VCPKG=ON -DCMAKE_BUILD_TYPE=Release \
58+
-DLINK_STATIC_GCC_CXX=ON \
5859
-DBUILD_TESTS=OFF -DBUILD_DYNAMIC_LIB=ON -DBUILD_STATIC_LIB=ON
5960
cmake --build build -j8
6061
./build-support/merge_archives_vcpkg.sh $PWD/build

0 commit comments

Comments
 (0)