Skip to content

Commit

Permalink
[pulsar-client-cpp] Fix build failure when CMAKE_BUILD_TYPE is not sp…
Browse files Browse the repository at this point in the history
…ecified (#36147)

* [pulsar-client-cpp] Fix build failure when CMAKE_BUILD_TYPE is not specified

* Force finding debug libraries by default
  • Loading branch information
BewareMyPower committed Jan 17, 2024
1 parent a1c22c4 commit 38d1652
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
25 changes: 14 additions & 11 deletions ports/pulsar-client-cpp/unofficial-pulsar-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@ if (NOT TARGET unofficial::pulsar::pulsar)
get_filename_component(VCPKG_IMPORT_PREFIX "${VCPKG_IMPORT_PREFIX}" PATH)
get_filename_component(VCPKG_IMPORT_PREFIX "${VCPKG_IMPORT_PREFIX}" PATH)

find_path(_pulsar_include_dir NAMES "pulsar/Client.h" PATH "${VCPKG_IMPORT_PREFIX}/include")
set(_temp_cmake_ignore_path ${CMAKE_IGNORE_PATH})
# Without setting CMAKE_IGNORE_PATH, the library under debug/lib/ directory could be found
set(CMAKE_IGNORE_PATH "${VCPKG_IMPORT_PREFIX}/debug/lib")
find_library(_pulsar_library_release NAMES pulsar pulsar-static PATH "${VCPKG_IMPORT_PREFIX}/lib")
set(CMAKE_IGNORE_PATH ${_temp_cmake_ignore_path})
unset(_temp_cmake_ignore_path)
find_library(_pulsar_library_debug NAMES pulsar pulsar-static PATH "${VCPKG_IMPORT_PREFIX}/debug/lib")
find_path(_pulsar_include_dir NAMES "pulsar/Client.h" PATHS "${VCPKG_IMPORT_PREFIX}/include" NO_DEFAULT_PATH)
find_library(_pulsar_library_release NAMES pulsar pulsar-static PATHS "${VCPKG_IMPORT_PREFIX}/lib" NO_DEFAULT_PATH)
find_library(_pulsar_library_debug NAMES pulsar pulsar-static PATHS "${VCPKG_IMPORT_PREFIX}/debug/lib" NO_DEFAULT_PATH)
message(STATUS "Found _pulsar_library_release: ${_pulsar_library_release}")
message(STATUS "Found _pulsar_library_debug: ${_pulsar_library_debug}")
if (NOT _pulsar_include_dir OR NOT _pulsar_library_release)
Expand All @@ -27,26 +22,32 @@ if (NOT TARGET unofficial::pulsar::pulsar)
message(STATUS "Found _pulsar_debug_dll: ${_pulsar_debug_dll}")
endif ()

# When CMAKE_BUILD_TYPE is not specified, debug libraries will be found for dependencies except ZLIB.
# So set it with Debug here to link debug ZLIB library by default.
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif ()

include(CMakeFindDependencyMacro)
find_dependency(OpenSSL)
find_dependency(ZLIB)
find_dependency(protobuf CONFIG)
find_dependency(CURL CONFIG)
find_dependency(zstd CONFIG)
find_dependency(snappy CONFIG)
find_dependency(Snappy CONFIG)
if (MSVC)
find_dependency(dlfcn-win32 CONFIG)
endif ()

if (_pulsar_release_dll)
add_library(unofficial::pulsar::pulsar SHARED IMPORTED)
set_target_properties(unofficial::pulsar::pulsar PROPERTIES
IMPORTED_CONFIGURATIONS "Release"
IMPORTED_CONFIGURATIONS "RELEASE"
IMPORTED_IMPLIB_RELEASE "${_pulsar_library_release}"
IMPORTED_LOCATION_RELEASE "${_pulsar_release_dll}")
if (_pulsar_debug_dll)
set_target_properties(unofficial::pulsar::pulsar PROPERTIES
IMPORTED_CONFIGURATIONS "Release;DEBUG"
IMPORTED_CONFIGURATIONS "DEBUG;RELEASE"
IMPORTED_IMPLIB_DEBUG "${_pulsar_library_debug}"
IMPORTED_LOCATION_DEBUG "${_pulsar_debug_dll}")
unset(_pulsar_debug_dll CACHE)
Expand All @@ -55,9 +56,11 @@ if (NOT TARGET unofficial::pulsar::pulsar)
else ()
add_library(unofficial::pulsar::pulsar UNKNOWN IMPORTED)
set_target_properties(unofficial::pulsar::pulsar PROPERTIES
IMPORTED_CONFIGURATIONS "RELEASE"
IMPORTED_LOCATION_RELEASE "${_pulsar_library_release}")
if (_pulsar_library_debug)
set_target_properties(unofficial::pulsar::pulsar PROPERTIES
IMPORTED_CONFIGURATIONS "DEBUG;RELEASE"
IMPORTED_LOCATION_DEBUG "${_pulsar_library_debug}")
unset(_pulsar_library_debug CACHE)
endif ()
Expand Down
1 change: 1 addition & 0 deletions ports/pulsar-client-cpp/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "pulsar-client-cpp",
"version": "3.4.2",
"port-version": 1,
"description": "The Apache Pulsar C++ library",
"homepage": "https://github.com/apache/pulsar-client-cpp",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -6878,7 +6878,7 @@
},
"pulsar-client-cpp": {
"baseline": "3.4.2",
"port-version": 0
"port-version": 1
},
"pulzed-mini": {
"baseline": "0.9.14",
Expand Down
5 changes: 5 additions & 0 deletions versions/p-/pulsar-client-cpp.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "4dc7014a2c8493a0124f08335cb9056c359604e4",
"version": "3.4.2",
"port-version": 1
},
{
"git-tree": "f022e5dacbf10b0a6cead0f065ce6ab885b4c9af",
"version": "3.4.2",
Expand Down

0 comments on commit 38d1652

Please sign in to comment.