mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-28 01:37:50 +08:00
dc19823670
* [pulsar-client-cpp] New port * Remove unnecessary link options * Address review comments - Use find_dependency instead of find_package - Specify BUILD_DYNAMIC_LIB explicitly * Fix the Windows build and linkage * Fix dynamic library not built when VCPKG_LIBRARY_LINKAGE is dynamic on Windows * Fix Linux and OSX failures * Remove PULSAR_FORCE_DYNAMIC_LIBRARY and upgrade version to 3.4.2 * Reduce the changes to the upstream CMakeLists.txt * Remove unused version * Optimize finding and linking dependency and patch the header for static library * Support multi-config generators * Fix path for release libraries
83 lines
3.1 KiB
Diff
83 lines
3.1 KiB
Diff
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
index fb4f1b1..1bcfd47 100644
|
|
--- a/CMakeLists.txt
|
|
+++ b/CMakeLists.txt
|
|
@@ -96,6 +96,7 @@ if (APPLE AND NOT LINK_STATIC)
|
|
else ()
|
|
set(LATEST_PROTOBUF FALSE)
|
|
endif ()
|
|
+set(LATEST_PROTOBUF FALSE)
|
|
|
|
if (NOT CMAKE_CXX_STANDARD)
|
|
if (LATEST_PROTOBUF)
|
|
@@ -157,14 +158,15 @@ if (LATEST_PROTOBUF)
|
|
# Use Config mode to avoid FindProtobuf.cmake does not find the Abseil library
|
|
find_package(Protobuf REQUIRED CONFIG)
|
|
else ()
|
|
- find_package(Protobuf REQUIRED)
|
|
+ find_package(protobuf CONFIG REQUIRED)
|
|
+ set(Protobuf_LIBRARIES protobuf::libprotobuf)
|
|
endif ()
|
|
message("Protobuf_INCLUDE_DIRS: " ${Protobuf_INCLUDE_DIRS})
|
|
message("Protobuf_LIBRARIES: " ${Protobuf_LIBRARIES})
|
|
|
|
# NOTE: CMake might not find curl and zlib on some platforms like Ubuntu, in this case, find them manually
|
|
set(CURL_NO_CURL_CMAKE ON)
|
|
-find_package(curl QUIET)
|
|
+find_package(CURL REQUIRED)
|
|
if (NOT CURL_FOUND)
|
|
find_path(CURL_INCLUDE_DIRS NAMES curl/curl.h)
|
|
find_library(CURL_LIBRARIES NAMES curl curllib libcurl_imp curllib_static libcurl)
|
|
@@ -175,7 +177,7 @@ if (NOT CURL_INCLUDE_DIRS OR NOT CURL_LIBRARIES)
|
|
message(FATAL_ERROR "Could not find libcurl")
|
|
endif ()
|
|
|
|
-find_package(zlib QUIET)
|
|
+find_package(ZLIB REQUIRED)
|
|
if (NOT ZLIB_FOUND)
|
|
find_path(ZLIB_INCLUDE_DIRS NAMES zlib.h)
|
|
find_library(ZLIB_LIBRARIES NAMES z zlib zdll zlib1 zlibstatic)
|
|
@@ -226,6 +228,17 @@ elseif (LINK_STATIC AND VCPKG_TRIPLET)
|
|
if (LIB_SNAPPY)
|
|
message(STATUS "Found Snappy library: ${LIB_SNAPPY}")
|
|
endif ()
|
|
+elseif (1)
|
|
+ find_package(zstd CONFIG REQUIRED)
|
|
+ set(HAS_ZSTD 1)
|
|
+ set(LIB_ZSTD
|
|
+ $<IF:$<TARGET_EXISTS:zstd::libzstd_shared>,zstd::libzstd_shared,zstd::libzstd_static>)
|
|
+ find_package(Snappy CONFIG REQUIRED)
|
|
+ set(HAS_SNAPPY 1)
|
|
+ set(LIB_SNAPPY Snappy::snappy)
|
|
+ if (MSVC)
|
|
+ find_package(dlfcn-win32 CONFIG REQUIRED)
|
|
+ endif ()
|
|
else()
|
|
if (MSVC AND (${CMAKE_BUILD_TYPE} STREQUAL Debug))
|
|
find_library(LIB_ZSTD zstdd HINTS "${VCPKG_DEBUG_ROOT}/lib")
|
|
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
|
|
index 8bd9749..551ac0c 100644
|
|
--- a/lib/CMakeLists.txt
|
|
+++ b/lib/CMakeLists.txt
|
|
@@ -31,12 +31,14 @@ include_directories(${LIB_AUTOGEN_DIR})
|
|
# Using custom command for now
|
|
set(PROTO_SOURCES ${LIB_AUTOGEN_DIR}/PulsarApi.pb.cc ${LIB_AUTOGEN_DIR}/PulsarApi.pb.h)
|
|
set(PULSAR_SOURCES ${PULSAR_SOURCES} ${PROTO_SOURCES})
|
|
-ADD_CUSTOM_COMMAND(
|
|
- OUTPUT ${PROTO_SOURCES}
|
|
- COMMAND ${PROTOC_PATH} -I ../proto ../proto/PulsarApi.proto --cpp_out=${LIB_AUTOGEN_DIR}
|
|
- DEPENDS
|
|
- ../proto/PulsarApi.proto
|
|
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
|
+
|
|
+add_library(proto-objects OBJECT "${CMAKE_SOURCE_DIR}/proto/PulsarApi.proto")
|
|
+target_link_libraries(proto-objects PUBLIC protobuf::libprotobuf)
|
|
+target_include_directories(proto-objects PUBLIC "${LIB_AUTOGEN_DIR}")
|
|
+protobuf_generate(
|
|
+ TARGET proto-objects
|
|
+ IMPORT_DIRS "${CMAKE_SOURCE_DIR}/proto"
|
|
+ PROTOC_OUT_DIR "${LIB_AUTOGEN_DIR}")
|
|
|
|
set(LIBRARY_VERSION $ENV{PULSAR_LIBRARY_VERSION})
|
|
if (NOT LIBRARY_VERSION)
|