From 41835971b727624588c7cb144bb4d72372162fca Mon Sep 17 00:00:00 2001 From: Ryan Schmidt Date: Sun, 21 May 2023 13:38:08 -0500 Subject: [PATCH] Fix pkg-config file to avoid overlinking When configured to use external protobuf, remove -lprotobuf-lite from pkg-config file's Libs section. The sentencepiece libraries link with libprotobuf-lite; it is not necessary for users of the sentencepiece libraries to link with protobuf unless they are using static linking so this should have been in Libs.private. Use Requires.private so that we use protobuf's pkg-config file to get the flags. --- CMakeLists.txt | 2 +- sentencepiece.pc.in | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a2f0f77b..28eb960a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,7 +75,7 @@ endif() if (SPM_USE_BUILTIN_PROTOBUF) set(libprotobuf_lite "") else() - set(libprotobuf_lite "-lprotobuf-lite") + set(libprotobuf_lite "protobuf-lite") endif() if (MSVC) diff --git a/sentencepiece.pc.in b/sentencepiece.pc.in index 8d80e7a0..1251dd22 100644 --- a/sentencepiece.pc.in +++ b/sentencepiece.pc.in @@ -6,5 +6,6 @@ includedir=@includedir_for_pc_file@ Name: @PROJECT_NAME@ Description: Unsupervised text tokenizer and detokenizer for Neural Network-based text generation. Version: @PROJECT_VERSION@ -Libs: -L${libdir} -lsentencepiece -lsentencepiece_train @libprotobuf_lite@ +Libs: -L${libdir} -lsentencepiece -lsentencepiece_train Cflags: -I${includedir} +Requires.private: @libprotobuf_lite@