From 965fbb43c7803dc2eb4ab86a4b459ecdbc461fb5 Mon Sep 17 00:00:00 2001
From: Adrien Beraud <adrien.beraud@savoirfairelinux.com>
Date: Wed, 15 Mar 2023 12:49:21 -0400
Subject: [PATCH] more attempts to find msgpackc-cxx in a universal way

---
 CMakeLists.txt | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 19de4358..fe1be1b6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -59,7 +59,10 @@ if (NOT MSVC)
     find_package (PkgConfig REQUIRED)
     pkg_search_module (GnuTLS REQUIRED IMPORTED_TARGET gnutls)
     pkg_search_module (Nettle REQUIRED IMPORTED_TARGET nettle)
-    find_package (msgpack REQUIRED NAMES msgpackc-cxx msgpack msgpack-cxx)
+    check_include_file_cxx(msgpack.hpp HAVE_MSGPACKCXX)
+    if (NOT HAVE_MSGPACKCXX)
+        find_package (msgpack REQUIRED CONFIG)
+    endif()
     if (OPENDHT_TOOLS)
         find_package (Readline 6 REQUIRED)
     endif ()
@@ -348,9 +351,11 @@ target_link_libraries(opendht
     PUBLIC
         ${CMAKE_THREAD_LIBS_INIT}
         PkgConfig::GnuTLS
-        msgpackc-cxx
         ${FMT_LIBRARY}
 )
+if (NOT HAVE_MSGPACKCXX)
+    target_link_libraries(opendht PUBLIC msgpackc-cxx)
+endif()
 if (Jsoncpp_FOUND)
     target_link_libraries(opendht PUBLIC PkgConfig::Jsoncpp)
 endif()
-- 
GitLab