# HG changeset patch # User Markus Mützel # Date 1629023358 -7200 # Node ID 00f871ed7aa2d8d5b723b6a74a7b4b243fa3d5cf # Parent 43d0785ca28f76374337c22ab7d5ccd691c63630 build: Allow disabling RapidJSON support by configure switch. * configure.ac: Add new switch "--disable-rapidjson". diff -r 43d0785ca28f -r 00f871ed7aa2 configure.ac --- a/configure.ac Sat Aug 14 22:53:30 2021 -0400 +++ b/configure.ac Sun Aug 15 12:29:18 2021 +0200 @@ -1378,43 +1378,50 @@ ### Check for RapidJSON header only library. +check_for_rapidjson=yes +AC_ARG_ENABLE([rapidjson], + [AS_HELP_STRING([--disable-rapidjson], + [disable rapidjson])], + [if test "$enableval" = no; then check_for_rapidjson=no; fi], []) warn_rapidjson= -AC_LANG_PUSH(C++) -AC_CHECK_HEADER([rapidjson/rapidjson.h], - [have_rapidjson=yes], - [have_rapidjson=no - warn_rapidjson="RapidJSON library not found. Octave will not be able to read or write JSON files."]) - -if test $have_rapidjson = yes; then - AC_DEFINE(HAVE_RAPIDJSON, 1, [Define to 1 if RapidJSON is available.]) - - ## Additional check on RapidJSON library that was found - ## Some features of the version of RapidJSON that is packaged in many - ## distributions do not build correctly with newer compilers. - ## See also: - ## https://github.com/Tencent/rapidjson/issues/909 - ## https://github.com/Tencent/rapidjson/issues/1718 - AC_CACHE_CHECK([for working PrettyWriter in RapidJSON], - [octave_cv_rapidjson_has_prettywriter], - [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - #include - ]], [[ - rapidjson::StringBuffer json; - rapidjson::PrettyWriter, - rapidjson::UTF8<>, rapidjson::CrtAllocator, - rapidjson::kWriteNanAndInfFlag> writer (json); - ]])], - [octave_cv_rapidjson_has_prettywriter=yes], - [octave_cv_rapidjson_has_prettywriter=no]) - ]) - if test $octave_cv_rapidjson_has_prettywriter = yes; then - AC_DEFINE(HAVE_RAPIDJSON_PRETTYWRITER, 1, - [Define to 1 if the RapidJSON PrettyWriter function is available.]) - else - warn_rapidjson='RapidJSON library found, but some features do not seem to work properly. The "PrettyWriter" option in jsonencode will be disabled.' +if test $check_for_rapidjson = yes; then + AC_LANG_PUSH(C++) + AC_CHECK_HEADER([rapidjson/rapidjson.h], + [have_rapidjson=yes], + [have_rapidjson=no + warn_rapidjson="RapidJSON library not found. Octave will not be able to read or write JSON files."]) + + if test $have_rapidjson = yes; then + AC_DEFINE(HAVE_RAPIDJSON, 1, [Define to 1 if RapidJSON is available.]) + + ## Additional check on RapidJSON library that was found + ## Some features of the version of RapidJSON that is packaged in many + ## distributions do not build correctly with newer compilers. + ## See also: + ## https://github.com/Tencent/rapidjson/issues/909 + ## https://github.com/Tencent/rapidjson/issues/1718 + AC_CACHE_CHECK([for working PrettyWriter in RapidJSON], + [octave_cv_rapidjson_has_prettywriter], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + ]], [[ + rapidjson::StringBuffer json; + rapidjson::PrettyWriter, + rapidjson::UTF8<>, rapidjson::CrtAllocator, + rapidjson::kWriteNanAndInfFlag> writer (json); + ]])], + [octave_cv_rapidjson_has_prettywriter=yes], + [octave_cv_rapidjson_has_prettywriter=no]) + ]) + if test $octave_cv_rapidjson_has_prettywriter = yes; then + AC_DEFINE(HAVE_RAPIDJSON_PRETTYWRITER, 1, + [Define to 1 if the RapidJSON PrettyWriter function is available.]) + else + warn_rapidjson='RapidJSON library found, but some features do not seem to work properly. The "PrettyWriter" option in jsonencode will be disabled.' + fi fi + AC_LANG_POP([C++]) fi -AC_LANG_POP([C++]) if test -n "$warn_rapidjson"; then OCTAVE_CONFIGURE_WARNING([warn_rapidjson])