From 4b35c63508c93d1ebcca4de78999c72489f2b9ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20R=C3=B6thke?= Date: Thu, 8 Sep 2022 13:02:45 +0200 Subject: [PATCH] cmake: prevent leak of libfmt dependency into spdlog users When linking dynamically against spdlog there is no need for the user of the shared library to itself link against the dependencies of that spdlog. Doing it anyway causes problems when one of the dependencies gets a soname bump, because now the library user needs to be rebuild despite not using a single symbol of the updated dependency. --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 975a0f6a..b0581847 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -213,7 +213,9 @@ if(SPDLOG_FMT_EXTERNAL OR SPDLOG_FMT_EXTERNAL_HO) target_link_libraries(spdlog_header_only INTERFACE fmt::fmt) endif() - set(PKG_CONFIG_REQUIRES fmt) # add dependency to pkg-config + if(NOT SPDLOG_BUILD_SHARED) + set(PKG_CONFIG_REQUIRES fmt) # add dependency to pkg-config + endif() endif() # ---------------------------------------------------------------------------------------