]> granicus.if.org Git - icinga2/commitdiff
Integrate nlohmann_json into CMake
authorMichael Friedrich <michael.friedrich@icinga.com>
Thu, 18 Oct 2018 13:22:50 +0000 (15:22 +0200)
committerAlexander A. Klimov <alexander.klimov@icinga.com>
Mon, 18 Mar 2019 14:07:50 +0000 (15:07 +0100)
Better integration into base/json.cpp

Signed-off-by: Alexander A. Klimov <alexander.klimov@icinga.com>
CMakeLists.txt
cmake/FindJSON.cmake [new file with mode: 0644]
lib/base/json.cpp

index 3556d3a9672c58bf2462ceecb1cca9bd707e9827..9c5a4f469d766c846362ca29edcddfce85b94820 100644 (file)
@@ -153,6 +153,10 @@ else()
   list(APPEND base_DEPS ${YAJL_LIBRARIES})
 endif()
 
+# JSON
+find_package(JSON)
+include_directories(${JSON_INCLUDE})
+
 find_package(Editline)
 set(HAVE_EDITLINE "${EDITLINE_FOUND}")
 
diff --git a/cmake/FindJSON.cmake b/cmake/FindJSON.cmake
new file mode 100644 (file)
index 0000000..b7d5d79
--- /dev/null
@@ -0,0 +1,9 @@
+FIND_PATH (JSON_INCLUDE json.hpp HINTS "${PROJECT_SOURCE_DIR}/third-party/nlohmann_json")
+
+if (JSON_INCLUDE)
+  set(JSON_BuildTests OFF CACHE INTERNAL "")
+
+  message(STATUS "Found JSON: ${JSON_INCLUDE}" )
+else ()
+  message(FATAL_ERROR "Unable to include json.hpp")
+endif ()
index a9a1e5f561786fb23c0c33248d8161a69c5e574f..13cb143f873ce3a5f5c3b84c1aed6a44db7d1d9f 100644 (file)
@@ -11,6 +11,7 @@
 #include <yajl/yajl_version.h>
 #include <yajl/yajl_gen.h>
 #include <yajl/yajl_parse.h>
+#include <json.hpp>
 #include <stack>
 
 using namespace icinga;