From 883c7657fbfc2ba1eab31fb82cc1e2fb02354b97 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Fri, 21 Jul 2023 13:16:11 -0400
Subject: [PATCH] cmake: use MSGPACK_LIB var

Change-Id: I0d1756a3150278a07b08d16e3dae988b782335de
---
 CMakeLists.txt | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e0bdd0d..d14bc98 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -17,9 +17,11 @@ set (VERSION ${CMAKE_PROJECT_VERSION})
 find_package (PkgConfig REQUIRED)
 
 find_package(msgpack-cxx CONFIG)
-if(NOT msgpack-cxx_FOUND)
+if(msgpack-cxx_FOUND)
+  set(MSGPACK_LIB msgpack-cxx)
+else()
   find_package(msgpackc-cxx CONFIG REQUIRED NAMES msgpackc-cxx msgpack)
-  add_library(msgpack-cxx ALIAS msgpackc-cxx)
+  set(MSGPACK_LIB msgpackc-cxx)
 endif()
 
 find_package(fmt)
@@ -69,7 +71,7 @@ list (APPEND dhtnet_HEADERS
 )
 
 add_library(dhtnet ${dhtnet_SOURCES})
-target_link_libraries(dhtnet PUBLIC PkgConfig::opendht PkgConfig::pjproject fmt::fmt msgpack-cxx)
+target_link_libraries(dhtnet PUBLIC PkgConfig::opendht PkgConfig::pjproject fmt::fmt ${MSGPACK_LIB})
 target_include_directories(dhtnet PUBLIC
     $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
     $<INSTALL_INTERFACE:include>
-- 
GitLab