Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed static linking on C++ lib on MacOS #5581

Merged
merged 3 commits into from
Feb 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions pulsar-client-cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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})
Expand Down
3 changes: 2 additions & 1 deletion pulsar-client-cpp/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down