Skip to content

Commit 4493fd9

Browse files
Allow to use system QJson. Closes qbittorrent#1744.
1 parent 3047681 commit 4493fd9

5 files changed

Lines changed: 165 additions & 4 deletions

File tree

configure

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,8 @@ EXPAND_BINDIR
601601
EXPAND_PREFIX
602602
zlib_LIBS
603603
zlib_CFLAGS
604+
qjson_LIBS
605+
qjson_CFLAGS
604606
libtorrent_LIBS
605607
libtorrent_CFLAGS
606608
BOOST_SYSTEM_LIB
@@ -716,6 +718,7 @@ with_qt5
716718
with_libtorrent_rasterbar0_16
717719
with_geoip_database_embedded
718720
with_qtsingleapplication
721+
with_qjson
719722
enable_debug
720723
enable_gui
721724
enable_systemd
@@ -742,6 +745,8 @@ PKG_CONFIG_LIBDIR
742745
QT_QMAKE
743746
libtorrent_CFLAGS
744747
libtorrent_LIBS
748+
qjson_CFLAGS
749+
qjson_LIBS
745750
zlib_CFLAGS
746751
zlib_LIBS'
747752

@@ -1389,6 +1394,9 @@ Optional Packages:
13891394
--with-qtsingleapplication=[system|shipped]
13901395
Use the shipped qtsingleapplication library or the
13911396
system one (default=shipped)
1397+
--with-qjson=[system|shipped]
1398+
Use the shipped qjson library or the system one
1399+
(default=shipped) (Qt4 only
13921400
--with-boost[=ARG] use Boost library from a standard location
13931401
(ARG=yes), from the specified location (ARG=<path>),
13941402
or disable it (ARG=no) [ARG=yes]
@@ -1423,6 +1431,9 @@ Some influential environment variables:
14231431
C compiler flags for libtorrent, overriding pkg-config
14241432
libtorrent_LIBS
14251433
linker flags for libtorrent, overriding pkg-config
1434+
qjson_CFLAGS
1435+
C compiler flags for qjson, overriding pkg-config
1436+
qjson_LIBS linker flags for qjson, overriding pkg-config
14261437
zlib_CFLAGS C compiler flags for zlib, overriding pkg-config
14271438
zlib_LIBS linker flags for zlib, overriding pkg-config
14281439
@@ -4200,6 +4211,15 @@ else
42004211
fi
42014212

42024213

4214+
4215+
# Check whether --with-qjson was given.
4216+
if test "${with_qjson+set}" = set; then :
4217+
withval=$with_qjson;
4218+
else
4219+
with_qjson=shipped
4220+
fi
4221+
4222+
42034223
# Check whether --enable-debug was given.
42044224
if test "${enable_debug+set}" = set; then :
42054225
enableval=$enable_debug;
@@ -5507,6 +5527,118 @@ $as_echo "$with_qtsingleapplication" >&6; }
55075527
as_fn_error $? "Unknown option \"$with_qtsingleapplication\". Use either \"system\" or \"shipped\"." "$LINENO" 5 ;;
55085528
esac
55095529

5530+
if test "x$with_qt5" = "xno"; then :
5531+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking which qjson to use" >&5
5532+
$as_echo_n "checking which qjson to use... " >&6; }
5533+
case "x$with_qjson" in #(
5534+
"xshipped") :
5535+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: shipped" >&5
5536+
$as_echo "shipped" >&6; }
5537+
QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG usesystemqjson" ;; #(
5538+
"xsystem") :
5539+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: system" >&5
5540+
$as_echo "system" >&6; }
5541+
5542+
pkg_failed=no
5543+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for qjson" >&5
5544+
$as_echo_n "checking for qjson... " >&6; }
5545+
5546+
if test -n "$qjson_CFLAGS"; then
5547+
pkg_cv_qjson_CFLAGS="$qjson_CFLAGS"
5548+
elif test -n "$PKG_CONFIG"; then
5549+
if test -n "$PKG_CONFIG" && \
5550+
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"QJson >= 0.8.1\""; } >&5
5551+
($PKG_CONFIG --exists --print-errors "QJson >= 0.8.1") 2>&5
5552+
ac_status=$?
5553+
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
5554+
test $ac_status = 0; }; then
5555+
pkg_cv_qjson_CFLAGS=`$PKG_CONFIG --cflags "QJson >= 0.8.1" 2>/dev/null`
5556+
test "x$?" != "x0" && pkg_failed=yes
5557+
else
5558+
pkg_failed=yes
5559+
fi
5560+
else
5561+
pkg_failed=untried
5562+
fi
5563+
if test -n "$qjson_LIBS"; then
5564+
pkg_cv_qjson_LIBS="$qjson_LIBS"
5565+
elif test -n "$PKG_CONFIG"; then
5566+
if test -n "$PKG_CONFIG" && \
5567+
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"QJson >= 0.8.1\""; } >&5
5568+
($PKG_CONFIG --exists --print-errors "QJson >= 0.8.1") 2>&5
5569+
ac_status=$?
5570+
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
5571+
test $ac_status = 0; }; then
5572+
pkg_cv_qjson_LIBS=`$PKG_CONFIG --libs "QJson >= 0.8.1" 2>/dev/null`
5573+
test "x$?" != "x0" && pkg_failed=yes
5574+
else
5575+
pkg_failed=yes
5576+
fi
5577+
else
5578+
pkg_failed=untried
5579+
fi
5580+
5581+
5582+
5583+
if test $pkg_failed = yes; then
5584+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
5585+
$as_echo "no" >&6; }
5586+
5587+
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
5588+
_pkg_short_errors_supported=yes
5589+
else
5590+
_pkg_short_errors_supported=no
5591+
fi
5592+
if test $_pkg_short_errors_supported = yes; then
5593+
qjson_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "QJson >= 0.8.1" 2>&1`
5594+
else
5595+
qjson_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "QJson >= 0.8.1" 2>&1`
5596+
fi
5597+
# Put the nasty error message in config.log where it belongs
5598+
echo "$qjson_PKG_ERRORS" >&5
5599+
5600+
as_fn_error $? "Package requirements (QJson >= 0.8.1) were not met:
5601+
5602+
$qjson_PKG_ERRORS
5603+
5604+
Consider adjusting the PKG_CONFIG_PATH environment variable if you
5605+
installed software in a non-standard prefix.
5606+
5607+
Alternatively, you may set the environment variables qjson_CFLAGS
5608+
and qjson_LIBS to avoid the need to call pkg-config.
5609+
See the pkg-config man page for more details." "$LINENO" 5
5610+
elif test $pkg_failed = untried; then
5611+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
5612+
$as_echo "no" >&6; }
5613+
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
5614+
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
5615+
as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it
5616+
is in your PATH or set the PKG_CONFIG environment variable to the full
5617+
path to pkg-config.
5618+
5619+
Alternatively, you may set the environment variables qjson_CFLAGS
5620+
and qjson_LIBS to avoid the need to call pkg-config.
5621+
See the pkg-config man page for more details.
5622+
5623+
To get pkg-config, see <http://pkg-config.freedesktop.org/>.
5624+
See \`config.log' for more details" "$LINENO" 5; }
5625+
else
5626+
qjson_CFLAGS=$pkg_cv_qjson_CFLAGS
5627+
qjson_LIBS=$pkg_cv_qjson_LIBS
5628+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
5629+
$as_echo "yes" >&6; }
5630+
CPPFLAGS="$qjson_CFLAGS $CPPFLAGS"
5631+
LIBS="$qjson_LIBS $LIBS"
5632+
fi
5633+
QBT_ADD_CONFIG="$QBT_ADD_CONFIG usesystemqjson" ;; #(
5634+
*) :
5635+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_qjson" >&5
5636+
$as_echo "$with_qjson" >&6; }
5637+
as_fn_error $? "Unknown option \"$with_qjson\". Use either \"system\" or \"shipped\"." "$LINENO" 5 ;;
5638+
esac
5639+
5640+
fi
5641+
55105642

55115643
pkg_failed=no
55125644
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for zlib" >&5

configure.ac

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ AC_ARG_WITH(qtsingleapplication,
3636
[],
3737
[with_qtsingleapplication=shipped])
3838

39+
AC_ARG_WITH(qjson,
40+
[AS_HELP_STRING([--with-qjson=@<:@system|shipped@:>@],
41+
[Use the shipped qjson library or the system one (default=shipped) (Qt4 only])],
42+
[],
43+
[with_qjson=shipped])
44+
3945
AC_ARG_ENABLE(debug,
4046
[AS_HELP_STRING([--enable-debug],
4147
[Enable debug build])],
@@ -214,6 +220,23 @@ AS_CASE(["x$with_qtsingleapplication"],
214220
[AC_MSG_RESULT([$with_qtsingleapplication])
215221
AC_MSG_ERROR([Unknown option "$with_qtsingleapplication". Use either "system" or "shipped".])])
216222

223+
AS_IF([test "x$with_qt5" = "xno"],
224+
[AC_MSG_CHECKING([which qjson to use])
225+
AS_CASE(["x$with_qjson"],
226+
["xshipped"],
227+
[AC_MSG_RESULT([shipped])
228+
QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG usesystemqjson"],
229+
["xsystem"],
230+
[AC_MSG_RESULT([system])
231+
PKG_CHECK_MODULES(qjson,
232+
[QJson >= 0.8.1],
233+
[CPPFLAGS="$qjson_CFLAGS $CPPFLAGS"
234+
LIBS="$qjson_LIBS $LIBS"])
235+
QBT_ADD_CONFIG="$QBT_ADD_CONFIG usesystemqjson"],
236+
[AC_MSG_RESULT([$with_qjson])
237+
AC_MSG_ERROR([Unknown option "$with_qjson". Use either "system" or "shipped".])])
238+
])
239+
217240
PKG_CHECK_MODULES(zlib,
218241
[zlib],
219242
[CPPFLAGS="$zlib_CFLAGS $CPPFLAGS"

src/app/application.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
#endif // DISABLE_GUI
5151

5252
#ifndef DISABLE_WEBUI
53-
#include "webui.h"
53+
#include "../webui/webui.h"
5454
#endif
5555

5656
#include "application.h"

src/webui/jsonutils.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,13 @@
3636
#include <QJsonArray>
3737
#else
3838
#include <QString>
39+
#ifndef USE_SYSTEM_QJSON
3940
#include "qjson/parser.h"
4041
#include "qjson/serializer.h"
42+
#else // USE_SYSTEM_QJSON
43+
#include <qjson/parser.h>
44+
#include <qjson/serializer.h>
45+
#endif // USE_SYSTEM_QJSON
4146
#endif
4247

4348
namespace json {

src/webui/webui.pri

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
INCLUDEPATH += $$PWD
2-
31
HEADERS += \
42
$$PWD/webui.h \
53
$$PWD/btjson.h \
@@ -20,6 +18,9 @@ SOURCES += \
2018
$$PWD/abstractwebapplication.cpp
2119

2220
# QJson JSON parser/serializer for using with Qt4
23-
lessThan(QT_MAJOR_VERSION, 5): include(qjson/qjson.pri)
21+
lessThan(QT_MAJOR_VERSION, 5) {
22+
!usesystemqjson: include(qjson/qjson.pri)
23+
else: DEFINES += USE_SYSTEM_QJSON
24+
}
2425

2526
RESOURCES += $$PWD/webui.qrc

0 commit comments

Comments
 (0)