diff --git a/NEWS.md b/NEWS.md index 84469959f..e45b49bbd 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 diff --git a/ac/nlohmann_jsoncpp.m4 b/ac/nlohmann_jsoncpp.m4 new file mode 100644 index 000000000..24fe5357f --- /dev/null +++ b/ac/nlohmann_jsoncpp.m4 @@ -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 + #include + #include + + #include + ],[ + nlohmann::json json{ + { "unsigned_64bit_integer", std::numeric_limits::max() }, + { "signed_64bit_integer", std::numeric_limits::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 diff --git a/configure.ac b/configure.ac index f08d61b46..d071701ed 100644 --- a/configure.ac +++ b/configure.ac @@ -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) diff --git a/debian-upstream/control b/debian-upstream/control index ea890cf5b..ecd592363 100644 --- a/debian-upstream/control +++ b/debian-upstream/control @@ -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 diff --git a/mkvtoolnix.spec b/mkvtoolnix.spec index cd593caf4..733fc24a6 100644 --- a/mkvtoolnix.spec +++ b/mkvtoolnix.spec @@ -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} diff --git a/src/common/id_info.h b/src/common/id_info.h index 76a9d28b3..c2acc5f0f 100644 --- a/src/common/id_info.h +++ b/src/common/id_info.h @@ -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 { diff --git a/src/common/json.h b/src/common/json.h index 0c4456658..2bddf9494 100644 --- a/src/common/json.h +++ b/src/common/json.h @@ -16,7 +16,11 @@ #include "common/common_pch.h" -#include "nlohmann-json/src/json.hpp" +#if defined(HAVE_NLOHMANN_JSONCPP) +# include +#else +# include "nlohmann-json/src/json.hpp" +#endif // HAVE_NLOHMANN_JSONCPP namespace mtx { namespace json { diff --git a/src/common/output.h b/src/common/output.h index 0fbe241b4..e17144646 100644 --- a/src/common/output.h +++ b/src/common/output.h @@ -20,9 +20,9 @@ #include +#include "common/json.h" #include "common/locale.h" #include "common/mm_io.h" -#include "nlohmann-json/src/json.hpp" using namespace libebml; diff --git a/src/merge/generic_reader.cpp b/src/merge/generic_reader.cpp index 2522a05a2..e5e9d1f19 100644 --- a/src/merge/generic_reader.cpp +++ b/src/merge/generic_reader.cpp @@ -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% diff --git a/src/mkvtoolnix-gui/util/json.h b/src/mkvtoolnix-gui/util/json.h index b2e762259..35bbc3bc2 100644 --- a/src/mkvtoolnix-gui/util/json.h +++ b/src/mkvtoolnix-gui/util/json.h @@ -3,7 +3,7 @@ #include "common/common_pch.h" -#include "nlohmann-json/src/json.hpp" +#include "common/json.h" class QVariant;