From 5a049f89f3b87fb8957b28b2ba0b7aab5757a74d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Wed, 8 Nov 2017 14:43:38 -0500
Subject: [PATCH] cmake: find Jsoncpp using pkgconfig

---
 CMakeLists.txt          |  6 +++++-
 cmake/FindJsoncpp.cmake | 18 ------------------
 2 files changed, 5 insertions(+), 19 deletions(-)
 delete mode 100644 cmake/FindJsoncpp.cmake

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4efc5af5..8d909a10 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -46,7 +46,7 @@ if (NOT OPENDHT_ARGON2)
 endif ()
 if (OPENDHT_PROXY_SERVER OR OPENDHT_PROXY_CLIENT)
     find_package(Restbed REQUIRED)
-    find_package(Jsoncpp REQUIRED)
+    pkg_search_module(Jsoncpp jsoncpp)
 endif()
 
 # Build flags
@@ -84,10 +84,14 @@ endif ()
 if (Nettle_INCLUDE_DIRS)
     include_directories (SYSTEM "${Nettle_INCLUDE_DIRS}")
 endif ()
+if (RESTBED_INCLUDE)
+    include_directories (SYSTEM "${RESTBED_INCLUDE}")
+endif ()
 if (Jsoncpp_INCLUDE_DIRS)
     include_directories (SYSTEM "${Jsoncpp_INCLUDE_DIRS}")
 endif ()
 link_directories (${Nettle_LIBRARY_DIRS})
+link_directories (${Jsoncpp_LIBRARY_DIRS})
 include_directories (
     ./
     include/
diff --git a/cmake/FindJsoncpp.cmake b/cmake/FindJsoncpp.cmake
deleted file mode 100644
index fccc2da3..00000000
--- a/cmake/FindJsoncpp.cmake
+++ /dev/null
@@ -1,18 +0,0 @@
-find_path (JSONCPP_INCLUDE jsoncpp
-           HINTS
-           "/usr/include"
-           "/usr/local/include"
-           "/opt/local/include"
-)
-
-if (JSONCPP_INCLUDE)
-    message(STATUS "${green}Found Jsoncpp: ${JSONCPP_INCLUDE}")
-else()
-    message(FATAL_ERROR "${red}Failed to locate Jsoncpp.}")
-endif()
-
-if (JSONCPP_INCLUDE)
-    set(JSONCPP_FOUND TRUE)
-    set(Jsoncpp_LIBRARIES jsoncpp)
-    set(Jsoncpp_INCLUDE_DIRS ${JSONCPP_INCLUDE}/jsoncpp)
-endif()
-- 
GitLab