add pkgconfig support for json-c
authorThomas Gstädtner <thomas@gstaedtner.net>
Tue, 5 Mar 2013 00:30:51 +0000 (01:30 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Tue, 5 Mar 2013 09:44:48 +0000 (10:44 +0100)
this includes a fallback for legacy support

CMakeLists.txt
blobmsg_json.h
jshn.c

index 941fd8e25381a5244e4c179248d2e02964abec43..f8388adac8b35fc86fa8ea30318f327fbea84327 100644 (file)
@@ -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})
index 4471a4e6bfe4865a837f39696cff26c3cb8580db..45ebd6df06347e911097ee95af575986beb15401 100644 (file)
 #ifndef __BLOBMSG_JSON_H
 #define __BLOBMSG_JSON_H
 
-#include <json/json.h>
+#ifdef JSONC
+       #include <json.h>
+#else
+       #include <json/json.h>
+#endif
+
 #include <stdbool.h>
 #include "blobmsg.h"
 
diff --git a/jshn.c b/jshn.c
index 9cbdb3194489d180406c8f656fa98d5c014c82aa..781861deda534602b560f138151534da55b91e31 100644 (file)
--- a/jshn.c
+++ b/jshn.c
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
-#include <json/json.h>
+#ifdef JSONC
+        #include <json.h>
+#else
+        #include <json/json.h>
+#endif
+
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>