From 972d4d28a11f1e642ba08ff6e6e81f488dcd0754 Mon Sep 17 00:00:00 2001
From: Adrien Beraud <adrien.beraud@savoirfairelinux.com>
Date: Fri, 5 Jul 2024 11:38:32 -0400
Subject: [PATCH] pkgconfig: add optional liburing dependency

---
 CMakeLists.txt | 1 +
 meson.build    | 1 +
 opendht.pc.in  | 2 +-
 3 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5d3570d5..57f767af 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -408,6 +408,7 @@ else()
         target_link_libraries(opendht PUBLIC PkgConfig::OPENSSL)
     endif()
     if (liburing_FOUND)
+        set(iouring_lib ", liburing")
         target_link_libraries(opendht PUBLIC PkgConfig::liburing)
         target_compile_definitions(opendht PUBLIC ASIO_HAS_IO_URING ASIO_DISABLE_EPOLL)
     endif()
diff --git a/meson.build b/meson.build
index 3c650d4d..eed85342 100644
--- a/meson.build
+++ b/meson.build
@@ -20,6 +20,7 @@ deps = [fmt, gnutls, nettle, msgpack, argon2, openssl, jsoncpp, llhttp, io_uring
 add_project_arguments('-DMSGPACK_NO_BOOST', '-DASIO_STANDALONE', language : 'cpp')
 if io_uring.found()
     add_project_arguments('-DASIO_HAS_IO_URING', '-DASIO_DISABLE_EPOLL', language : 'cpp')
+    conf_data.set('iouring_lib', ', liburing')
 endif
 add_project_arguments(['-Wno-return-type','-Wno-deprecated','-Wnon-virtual-dtor','-pedantic-errors','-fvisibility=hidden'], language : 'cpp')
 
diff --git a/opendht.pc.in b/opendht.pc.in
index 8526b697..63de4294 100644
--- a/opendht.pc.in
+++ b/opendht.pc.in
@@ -8,5 +8,5 @@ Version: @VERSION@
 Libs: -L${libdir} -lopendht
 Libs.private: @http_lib@ -pthread
 Requires: gnutls >= 3.3@jsoncpp_lib@@openssl_lib@
-Requires.private: nettle >= 2.4@argon2_lib@
+Requires.private: nettle >= 2.4@argon2_lib@@iouring_lib@
 Cflags: -I${includedir}
-- 
GitLab