vcpkg/ports/pulsar-client-cpp/portfile.cmake
Yunze Xu dc19823670
[pulsar-client-cpp] New port (#35579)
* [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
2023-12-29 00:15:51 -08:00

42 lines
1.4 KiB
CMake

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO apache/pulsar-client-cpp
REF "v${VERSION}"
SHA512 b1f56ca8d5edb7faaba68eb4e04fcb4e458ccf2c7a5b0fb6d66868c6507081344fb3f0ebb29afe9aef567295a249b09cdeb3fb00285746767bbccef65a0f6e70
HEAD_REF main
PATCHES
0001-use-find-package.patch
)
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" BUILD_STATIC_LIB)
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" BUILD_DYNAMIC_LIB)
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DBUILD_TESTS=OFF
-DBUILD_PERF_TOOLS=OFF
-DBUILD_DYNAMIC_LIB=${BUILD_DYNAMIC_LIB}
-DBUILD_STATIC_LIB=${BUILD_STATIC_LIB}
)
vcpkg_cmake_install()
if (BUILD_STATIC_LIB)
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/pulsar/defines.h"
"#ifdef PULSAR_STATIC"
"#if 1")
endif ()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin")
endif()
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
configure_file("${CMAKE_CURRENT_LIST_DIR}/usage" "${CURRENT_PACKAGES_DIR}/share/${PORT}/usage" COPYONLY)
configure_file("${CMAKE_CURRENT_LIST_DIR}/unofficial-pulsar-config.cmake" "${CURRENT_PACKAGES_DIR}/share/unofficial-pulsar/unofficial-pulsar-config.cmake" @ONLY)
vcpkg_copy_pdbs()