mkvtoolnix/ac/nlohmann_jsoncpp.m4
Moritz Bunkus f8e425714e configure: look for nlohmann/json.hpp first, json.hpp second
The upstream project intends the include files to be installed in
`$includedir/nlohmann/json.hpp`,
e.g. `/usr/include/nlohmann/json.hpp`. Debian did not follow that
recommendation and installed them directly in `$includedir`. Therefore
`configure` was only looking for the latter, not the former.

However, Debian will soon follow suit. Therefore detection has been
extended to check for the intended location first.

Fixes #2048.
2017-07-17 20:58:19 +02:00

59 lines
1.6 KiB
Plaintext

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_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$STD_CXX $CXXFLAGS"
AC_TRY_COMPILE([
#include <cstdint>
#include <iostream>
#include <limits>
#include <nlohmann/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=undetermined])
if test x"$ac_cv_nlohmann_jsoncpp" = xundetermined; then
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, without the nlohmann subdir"],[ac_cv_nlohmann_jsoncpp=no])
fi
CXXFLAGS="$ac_save_CXXFLAGS"
AC_LANG_POP
])
if test x"$ac_cv_nlohmann_jsoncpp" = xno; then
AC_MSG_NOTICE([Using the internal version of nlohmann json-cpp])
else
AC_MSG_NOTICE([Using the system version of nlohmann json-cpp])
if test x"$ac_cv_nlohmann_jsoncpp" = xyes; then
AC_DEFINE([HAVE_NLOHMANN_JSONCPP],[1],[Define if nlohmann's json-cpp is available.])
else
AC_DEFINE([HAVE_NLOHMANN_JSONCPP],[2],[Define if nlohmann's json-cpp is available.])
fi
fi