From 3b389187ceefb3bfe02b0277a9df0726a93ad08c Mon Sep 17 00:00:00 2001 From: Andre Sailer Date: Tue, 3 Dec 2024 19:07:04 -0800 Subject: [PATCH] PkgConfig: account for possible debug postfix in library name (#19444) PkgConfig: account for possible debug postfix in library name, this fixes #19325 Closes #19444 COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/19444 from andresailer:pkgConfigD 8f353cb6ca839ec9d48684fc1e9b45b7a61fe224 PiperOrigin-RevId: 702547617 --- cmake/install.cmake | 4 ++++ cmake/protobuf.pc.cmake | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cmake/install.cmake b/cmake/install.cmake index bf565098443e..4493e237286e 100644 --- a/cmake/install.cmake +++ b/cmake/install.cmake @@ -20,6 +20,10 @@ if (protobuf_BUILD_SHARED_LIBS) set(_protobuf_PC_CFLAGS -DPROTOBUF_USE_DLLS) endif () +if(CMAKE_BUILD_TYPE STREQUAL Debug) + # attach debug postfix only in debug mode + set(protobuf_LIBRARY_POSTFIX ${protobuf_DEBUG_POSTFIX}) +endif() configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/protobuf.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/protobuf.pc @ONLY) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/protobuf-lite.pc.cmake diff --git a/cmake/protobuf.pc.cmake b/cmake/protobuf.pc.cmake index 81d87c1f7019..f1407116eb6f 100644 --- a/cmake/protobuf.pc.cmake +++ b/cmake/protobuf.pc.cmake @@ -7,6 +7,6 @@ Name: Protocol Buffers Description: Google's Data Interchange Format Version: @protobuf_VERSION@ Requires: @_protobuf_PC_REQUIRES@ -Libs: -L${libdir} -lprotobuf @CMAKE_THREAD_LIBS_INIT@ +Libs: -L${libdir} -lprotobuf@protobuf_LIBRARY_POSTFIX@ @CMAKE_THREAD_LIBS_INIT@ Cflags: -I${includedir} @_protobuf_PC_CFLAGS@ Conflicts: protobuf-lite