From 49e6e062b8effe281a85de167c16c5f039b74442 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Gst=C3=A4dtner?= Date: Tue, 5 Mar 2013 01:30:51 +0100 Subject: [PATCH] add pkgconfig support for json-c this includes a fallback for legacy support --- CMakeLists.txt | 7 +++++++ blobmsg_json.h | 7 ++++++- jshn.c | 7 ++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 941fd8e..f8388ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,13 @@ IF(APPLE) LINK_DIRECTORIES(/opt/local/lib) ENDIF() +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(JSONC json) +IF(JSONC_FOUND) + ADD_DEFINITIONS(-DJSONC) + INCLUDE_DIRECTORIES(${JSONC_INCLUDE_DIRS}) +ENDIF() + SET(SOURCES avl.c avl-cmp.c blob.c blobmsg.c uloop.c usock.c ustream.c ustream-fd.c vlist.c utils.c) ADD_LIBRARY(ubox SHARED ${SOURCES}) diff --git a/blobmsg_json.h b/blobmsg_json.h index 4471a4e..45ebd6d 100644 --- a/blobmsg_json.h +++ b/blobmsg_json.h @@ -16,7 +16,12 @@ #ifndef __BLOBMSG_JSON_H #define __BLOBMSG_JSON_H -#include +#ifdef JSONC + #include +#else + #include +#endif + #include #include "blobmsg.h" diff --git a/jshn.c b/jshn.c index 9cbdb31..781861d 100644 --- a/jshn.c +++ b/jshn.c @@ -13,7 +13,12 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include +#ifdef JSONC + #include +#else + #include +#endif + #include #include #include