diff --git a/pulsar-client-cpp/CMakeLists.txt b/pulsar-client-cpp/CMakeLists.txt index fd010b9a71aff..6357021ba2be3 100644 --- a/pulsar-client-cpp/CMakeLists.txt +++ b/pulsar-client-cpp/CMakeLists.txt @@ -74,6 +74,12 @@ endif(NOT LOG_CATEGORY_NAME) add_definitions(-DLOG_CATEGORY_NAME=${LOG_CATEGORY_NAME} -DBUILDING_PULSAR -DBOOST_ALL_NO_LIB -DBOOST_ALLOW_DEPRECATED_HEADERS) if (LINK_STATIC) + find_library(ZLIB_LIBRARIES REQUIRED NAMES libz.a z) + find_library(Protobuf_LITE_LIBRARIES NAMES libprotobuf-lite.a) + find_library(CURL_LIBRARIES NAMES libcurl.a curl curl_a) + find_library(LIB_ZSTD NAMES libzstd.a) + find_library(LIB_SNAPPY NAMES libsnappy.a) + if (USE_LOG4CXX) if (LOG4CXX_USE_DYNAMIC_LIBS) find_library(LOG4CXX_LIBRARY_PATH log4cxx) @@ -104,6 +110,19 @@ if (LINK_STATIC) SET(OPENSSL_USE_STATIC_LIBS TRUE) else() # Link to shared libraries + find_package(ZLIB REQUIRED) + set(ZLIB_LIBRARIES ${ZLIB_LIBRARIES}) + if (NOT PROTOBUF_LIBRARIES) + find_package(ProtoBuf QUIET) + if (NOT Protobuf_FOUND OR NOT Protobuf_LITE_LIBRARIES) + find_library(Protobuf_LITE_LIBRARIES protobuf-lite libprotobuf-lite) + find_path(Protobuf_INCLUDE_DIRS google/protobuf/stubs/common.h) + endif() + endif (NOT PROTOBUF_LIBRARIES) + + find_library(LIB_ZSTD zstd) + find_library(LIB_SNAPPY snappy libsnappy) + find_library(CURL_LIBRARIES curl) if (USE_LOG4CXX) find_library(LOG4CXX_LIBRARY_PATH log4cxx) find_path(LOG4CXX_INCLUDE_PATH log4cxx/logger.h) @@ -116,24 +135,6 @@ else() find_package(Boost REQUIRED COMPONENTS program_options regex system) endif() -find_package(ZLIB REQUIRED) - -find_package(Protobuf QUIET) -if (NOT Protobuf_FOUND OR NOT Protobuf_LITE_LIBRARIES) - find_library(Protobuf_LITE_LIBRARIES protobuf-lite libprotobuf-lite) - find_path(Protobuf_INCLUDE_DIRS google/protobuf/stubs/common.h) -endif() - -find_package(CURL QUIET) -if (NOT CURL_FOUND) - find_library(CURL_LIBRARIES NAMES curl libcurl_a) - find_path(CURL_INCLUDE_DIRS curl/curl.h) -endif() - -find_library(LIB_ZSTD zstd libzstd) - -find_library(LIB_SNAPPY snappy libsnappy) - if (BUILD_PYTHON_WRAPPER) find_package(PythonLibs REQUIRED) MESSAGE(STATUS "PYTHON: " ${PYTHONLIBS_VERSION_STRING}) diff --git a/pulsar-client-cpp/python/CMakeLists.txt b/pulsar-client-cpp/python/CMakeLists.txt index 5421cbc78389e..1cbc9728d23f3 100644 --- a/pulsar-client-cpp/python/CMakeLists.txt +++ b/pulsar-client-cpp/python/CMakeLists.txt @@ -51,7 +51,7 @@ set(PYTHON_WRAPPER_LIBS ${Boost_PYTHON_LIBRARY} ${Boost_PYTHON3_LIBRARY} ${Boost_PYTHON36_LIBRARY}) if (APPLE) - set(PYTHON_WRAPPER_LIBS ${PYTHON_LIBRARIES} ${PYTHON_WRAPPER_LIBS} + set(PYTHON_WRAPPER_LIBS ${PYTHON_WRAPPER_LIBS} ${Boost_PYTHON27-MT_LIBRARY_RELEASE} ${Boost_PYTHON37-MT_LIBRARY_RELEASE}) if (LINK_STATIC) @@ -71,6 +71,7 @@ if (NOT PYTHON_WRAPPER_LIBS) endif () if (APPLE) + set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} -undefined dynamic_lookup") target_link_libraries(_pulsar -Wl,-all_load pulsarStatic ${PYTHON_WRAPPER_LIBS} ${COMMON_LIBS} ${ICU_LIBS}) else () if (NOT MSVC)