diff --git a/pulsar-client-cpp/docker/build-client-lib-within-docker.sh b/pulsar-client-cpp/docker/build-client-lib-within-docker.sh index 3a356cc7466ae5..364c82abcbb400 100755 --- a/pulsar-client-cpp/docker/build-client-lib-within-docker.sh +++ b/pulsar-client-cpp/docker/build-client-lib-within-docker.sh @@ -31,4 +31,4 @@ cmake . -DBUILD_TESTS=OFF -DLINK_STATIC=ON \ -DPYTHON_INCLUDE_DIR=/opt/python/$PYTHON_SPEC/include/python$PYTHON_VERSION \ -DPYTHON_LIBRARY=/opt/python/$PYTHON_SPEC/lib \ -make pulsarShared pulsarStatic -j4 +make pulsarShared pulsarStatic pulsarStaticNossl -j4 diff --git a/pulsar-client-cpp/lib/CMakeLists.txt b/pulsar-client-cpp/lib/CMakeLists.txt index db514f1d2a505b..64b892beb6f35e 100644 --- a/pulsar-client-cpp/lib/CMakeLists.txt +++ b/pulsar-client-cpp/lib/CMakeLists.txt @@ -57,16 +57,23 @@ if (WIN32) string(APPEND LIB_NAME_SHARED dll) endif() -add_library(pulsarShared SHARED ${PULSAR_SOURCES}) -set_target_properties(pulsarShared PROPERTIES OUTPUT_NAME ${LIB_NAME_SHARED} VERSION ${LIBRARY_VERSION}) -target_link_libraries(pulsarShared ${COMMON_LIBS} ${CMAKE_DL_LIBS}) +set(LIB_NAME_NOSSL ${LIB_NAME}nossl) add_library(pulsarStatic STATIC ${PULSAR_SOURCES}) set_target_properties(pulsarStatic PROPERTIES OUTPUT_NAME ${LIB_NAME} VERSION ${LIBRARY_VERSION}) target_compile_definitions(pulsarStatic PRIVATE PULSAR_STATIC) +add_library(pulsarStaticNossl STATIC ${PULSAR_SOURCES}) +set_target_properties(pulsarStaticNossl PROPERTIES OUTPUT_NAME ${LIB_NAME_NOSSL} VERSION ${LIBRARY_VERSION}) +target_compile_definitions(pulsarStaticNossl PRIVATE PULSAR_STATIC) + +add_library(pulsarShared SHARED ${PULSAR_SOURCES}) +set_target_properties(pulsarShared PROPERTIES OUTPUT_NAME ${LIB_NAME_SHARED} VERSION ${LIBRARY_VERSION}) +target_link_libraries(pulsarShared ${COMMON_LIBS} ${CMAKE_DL_LIBS}) + if (MSVC) target_include_directories(pulsarStatic PRIVATE ${dlfcn-win32_INCLUDE_DIRS}) + target_include_directories(pulsarStaticNossl PRIVATE ${dlfcn-win32_INCLUDE_DIRS}) target_include_directories(pulsarShared PRIVATE ${dlfcn-win32_INCLUDE_DIRS}) target_link_options(pulsarShared PRIVATE $<$:/NODEFAULTLIB:MSVCRT>) endif() @@ -97,6 +104,13 @@ if (LINK_STATIC) remove_libtype("${COMMON_LIBS}" "debug" STATIC_LIBS) set_target_properties(pulsarStaticWithDeps PROPERTIES STATIC_LIBRARY_FLAGS_DEBUG ${DEBUG_STATIC_LIBS} STATIC_LIBRARY_FLAGS_RELEASE ${STATIC_LIBS} OUTPUT_NAME ${LIB_NAME}WithDeps VERSION ${LIBRARY_VERSION}) install(TARGETS pulsarStaticWithDeps DESTINATION lib) + + add_library(pulsarStaticWithDepsNossl STATIC ${PULSAR_SOURCES}) + target_include_directories(pulsarStaticWithDepsNossl PRIVATE ${dlfcn-win32_INCLUDE_DIRS}) + remove_libtype("${COMMON_LIBS}" "optimized" DEBUG_STATIC_LIBS) + remove_libtype("${COMMON_LIBS}" "debug" STATIC_LIBS) + set_target_properties(pulsarStaticWithDepsNossl PROPERTIES STATIC_LIBRARY_FLAGS_DEBUG ${DEBUG_STATIC_LIBS} STATIC_LIBRARY_FLAGS_RELEASE ${STATIC_LIBS} OUTPUT_NAME ${LIB_NAME}WithDepsNossl VERSION ${LIBRARY_VERSION}) + install(TARGETS pulsarStaticWithDeps DESTINATION lib) else() # Build a list of the requird .a libs to merge SET(STATIC_LIBS "") @@ -113,6 +127,26 @@ if (LINK_STATIC) DEPENDS pulsarStatic WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) install(FILES ../merged-library/libpulsar.a DESTINATION lib) + + # libpulsarnossl.a is similar as build libpulsar.a, except no OPENSSL_SSL_LIBRARY and OPENSSL_CRYPTO_LIBRARY + message("Modified libraries list, remove ${OPENSSL_SSL_LIBRARY} and ${OPENSSL_CRYPTO_LIBRARY}") + LIST(REMOVE_ITEM COMMON_LIBS ${OPENSSL_SSL_LIBRARY}) + LIST(REMOVE_ITEM COMMON_LIBS ${OPENSSL_CRYPTO_LIBRARY}) + SET(STATIC_LIBS_NOSSL "") + foreach (LIB IN LISTS COMMON_LIBS) + if (${LIB} MATCHES ".+\\.a$") + set(STATIC_LIBS_NOSSL "${STATIC_LIBS_NOSSL} ${LIB}") + endif() + endforeach() + message(${STATIC_LIBS_NOSSL}) + add_custom_target(pulsarStaticWithDepsNossl + ALL + BYPRODUCTS merged-library + COMMAND ./build-support/merge_archives.sh libpulsarnossl.a $ ${STATIC_LIBS_NOSSL} + DEPENDS pulsarStaticNossl + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) + install(FILES ../merged-library/libpulsarnossl.a DESTINATION lib) + endif(MSVC) else() # Install regular libpulsar.a @@ -121,5 +155,6 @@ else() endif(LINK_STATIC) install(TARGETS pulsarStatic DESTINATION lib) +install(TARGETS pulsarStaticNossl DESTINATION lib) install(TARGETS pulsarShared RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) install(DIRECTORY "../include/pulsar" DESTINATION include) diff --git a/pulsar-client-cpp/pkg/deb/build-deb.sh b/pulsar-client-cpp/pkg/deb/build-deb.sh index 84f1f81bd3b163..8925304c8abd9e 100755 --- a/pulsar-client-cpp/pkg/deb/build-deb.sh +++ b/pulsar-client-cpp/pkg/deb/build-deb.sh @@ -38,7 +38,7 @@ tar xfz $SRC_ROOT_DIR/distribution/server/target/apache-pulsar-$POM_VERSION-src. pushd $CPP_DIR cmake . -DBUILD_TESTS=OFF -DLINK_STATIC=ON -make pulsarShared pulsarStatic -j 3 +make pulsarShared pulsarStatic pulsarStaticNossl -j 3 popd DEST_DIR=apache-pulsar-client @@ -70,6 +70,7 @@ mkdir -p $DEVEL_DEST_DIR/usr/share/doc/pulsar-client-dev-$VERSION cp -ar $CPP_DIR/include/pulsar $DEVEL_DEST_DIR/usr/include/ cp $CPP_DIR/lib/libpulsar.a $DEVEL_DEST_DIR/usr/lib +cp $CPP_DIR/lib/libpulsarnossl.a $DEVEL_DEST_DIR/usr/lib cp $CPP_DIR/lib/libpulsar.so.$POM_VERSION $DEST_DIR/usr/lib pushd $DEST_DIR/usr/lib ln -s libpulsar.so.$POM_VERSION libpulsar.so diff --git a/pulsar-client-cpp/pkg/rpm/SPECS/pulsar-client.spec b/pulsar-client-cpp/pkg/rpm/SPECS/pulsar-client.spec index aed4d31a6e2360..f4ea064565bab2 100644 --- a/pulsar-client-cpp/pkg/rpm/SPECS/pulsar-client.spec +++ b/pulsar-client-cpp/pkg/rpm/SPECS/pulsar-client.spec @@ -53,7 +53,7 @@ static library. %build cd pulsar-client-cpp cmake . -DBUILD_TESTS=OFF -DLINK_STATIC=ON -DBUILD_PYTHON_WRAPPER=OFF -make pulsarShared pulsarStatic -j 3 +make pulsarShared pulsarStatic pulsarStaticNossl -j 3 %install cd pulsar-client-cpp @@ -65,6 +65,7 @@ mkdir -p $INCLUDE_DIR $LIB_DIR $DOC_DIR $DOC_DEVEL_DIR cp -ar include/pulsar $INCLUDE_DIR cp lib/libpulsar.a $LIB_DIR +cp lib/libpulsarnossl.a $LIB_DIR cp lib/libpulsar.so.%{pom_version} $LIB_DIR # Copy LICENSE files @@ -87,3 +88,9 @@ ln -s libpulsar.so.%{pom_version} libpulsar.so /usr/lib/libpulsar.a /usr/include/pulsar /usr/share/doc/pulsar-client-devel-%{version} + +%files devel-nossl +%defattr(-,root,root) +/usr/lib/libpulsarnossl.a +/usr/include/pulsar +/usr/share/doc/pulsar-client-devel-nossl-%{version}