build system: look for & use system-wide version of nlohmann json-cpp

If one is found, it will be used. Otherwise the included version in
lib/nlohmann-json will be used.

Implements #1858.
This commit is contained in:
Moritz Bunkus 2017-01-20 23:06:21 +01:00
parent 5fe1b0be03
commit e52f878720
10 changed files with 46 additions and 6 deletions

View File

@ -48,6 +48,9 @@
## Build system changes
* nlohman json-cpp: configure now looks for a system-wide installed version of
the nlohmann json-cpp header-only library. If one is found, it is used;
otherwise the included version will be used. Implements #1858.
* If MKVToolNix is built with rake v10.0.0 or newer, its "multitask" feature
will be turned on allowing automatic parallel builds.
* CURL is no longer used by MKVToolNix and is therefore not required

32
ac/nlohmann_jsoncpp.m4 Normal file
View File

@ -0,0 +1,32 @@
dnl
dnl Check for nlohmann's json-cpp library
dnl
AC_CACHE_CHECK([nlohmann's json-cpp],[ac_cv_nlohmann_jsoncpp],[
AC_LANG_PUSH(C++)
AC_TRY_COMPILE([
#include <cstdint>
#include <iostream>
#include <limits>
#include <json.hpp>
],[
nlohmann::json json{
{ "unsigned_64bit_integer", std::numeric_limits<std::uint64_t>::max() },
{ "signed_64bit_integer", std::numeric_limits<std::int64_t>::min() },
};
std::cout << json.dump();
],[ac_cv_nlohmann_jsoncpp=yes],[ac_cv_nlohmann_jsoncpp=no])
AC_LANG_POP
])
if test x"$ac_cv_nlohmann_jsoncpp" = xyes; then
AC_MSG_NOTICE([Using the system version of nlohmann json-cpp])
AC_DEFINE([HAVE_NLOHMANN_JSONCPP],[1],[Define if nlohmann's json-cpp is available.])
else
AC_MSG_NOTICE([Using the internal version of nlohmann json-cpp])
fi

View File

@ -29,6 +29,7 @@ m4_include(ac/vorbis.m4)
m4_include(ac/flac.m4)
m4_include(ac/matroska.m4)
m4_include(ac/pugixml.m4)
m4_include(ac/nlohmann_jsoncpp.m4)
m4_include(ac/utf8cpp.m4)
m4_include(ac/zlib.m4)
m4_include(ac/qt5.m4)

View File

@ -12,6 +12,7 @@ Build-Depends:
libboost-dev (>= 1.46), libboost-filesystem-dev (>= 1.46),
libboost-regex-dev (>= 1.46), libboost-date-time-dev (>= 1.46),
libboost-system-dev (>= 1.46), qtbase5-dev, qtbase5-dev-tools,
base-files (< 9.6) | nlohmann-json-dev (>= 2),
pkg-config
Package: mkvtoolnix

View File

@ -26,7 +26,7 @@ BuildRequires: gcc5-c++
%endif
%if 0%{?fedora}
BuildRequires: gcc-c++ >= 4.9.0, rubypick, pugixml-devel, rubygem-rake
BuildRequires: gcc-c++ >= 4.9.0, rubypick, pugixml-devel, rubygem-rake, json-devel >= 2
%endif
%if 0%{?suse_version}

View File

@ -14,8 +14,8 @@
#include "common/common_pch.h"
#include "common/json.h"
#include "common/strings/editing.h"
#include "nlohmann-json/src/json.hpp"
namespace mtx { namespace id {

View File

@ -16,7 +16,11 @@
#include "common/common_pch.h"
#include "nlohmann-json/src/json.hpp"
#if defined(HAVE_NLOHMANN_JSONCPP)
# include <json.hpp>
#else
# include "nlohmann-json/src/json.hpp"
#endif // HAVE_NLOHMANN_JSONCPP
namespace mtx { namespace json {

View File

@ -20,9 +20,9 @@
#include <ebml/EbmlElement.h>
#include "common/json.h"
#include "common/locale.h"
#include "common/mm_io.h"
#include "nlohmann-json/src/json.hpp"
using namespace libebml;

View File

@ -19,7 +19,6 @@
#include "merge/generic_reader.h"
#include "merge/input_x.h"
#include "merge/output_control.h"
#include "nlohmann-json/src/json.hpp"
static int64_rational_c s_probe_range_percentage{3, 10}; // 0.3%

View File

@ -3,7 +3,7 @@
#include "common/common_pch.h"
#include "nlohmann-json/src/json.hpp"
#include "common/json.h"
class QVariant;