From e47d90b5a624f12e30749a9be0e364b5fd016228 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Thu, 29 Jul 2021 14:09:37 +0800 Subject: [PATCH 1/4] Update pkg.m4 to latest version Upstream: https://gitlab.freedesktop.org/pkg-config/pkg-config/-/blob/master/pkg.m4.in --- m4/pkg.m4 | 223 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 142 insertions(+), 81 deletions(-) diff --git a/m4/pkg.m4 b/m4/pkg.m4 index 13e67d5f5..13a889017 100644 --- a/m4/pkg.m4 +++ b/m4/pkg.m4 @@ -1,29 +1,60 @@ -# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- -# serial 1 (pkg-config-0.24) -# -# Copyright © 2004 Scott James Remnant . -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# PKG_PROG_PKG_CONFIG([MIN-VERSION]) -# ---------------------------------- +# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- +# serial 12 (pkg-config-0.29.2) + +dnl Copyright © 2004 Scott James Remnant . +dnl Copyright © 2012-2015 Dan Nicholson +dnl +dnl This program is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 2 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +dnl 02111-1307, USA. +dnl +dnl As a special exception to the GNU General Public License, if you +dnl distribute this file as part of a program that contains a +dnl configuration script generated by Autoconf, you may include it under +dnl the same distribution terms that you use for the rest of that +dnl program. + +dnl PKG_PREREQ(MIN-VERSION) +dnl ----------------------- +dnl Since: 0.29 +dnl +dnl Verify that the version of the pkg-config macros are at least +dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's +dnl installed version of pkg-config, this checks the developer's version +dnl of pkg.m4 when generating configure. +dnl +dnl To ensure that this macro is defined, also add: +dnl m4_ifndef([PKG_PREREQ], +dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])]) +dnl +dnl See the "Since" comment for each macro you use to see what version +dnl of the macros you require. +m4_defun([PKG_PREREQ], +[m4_define([PKG_MACROS_VERSION], [0.29.2]) +m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1, + [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])]) +])dnl PKG_PREREQ + +dnl PKG_PROG_PKG_CONFIG([MIN-VERSION]) +dnl ---------------------------------- +dnl Since: 0.16 +dnl +dnl Search for the pkg-config tool and set the PKG_CONFIG variable to +dnl first found in the path. Checks that the version of pkg-config found +dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is +dnl used since that's the first version where most current features of +dnl pkg-config existed. AC_DEFUN([PKG_PROG_PKG_CONFIG], [m4_pattern_forbid([^_?PKG_[A-Z_]+$]) m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) @@ -45,18 +76,19 @@ if test -n "$PKG_CONFIG"; then PKG_CONFIG="" fi fi[]dnl -])# PKG_PROG_PKG_CONFIG - -# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) -# -# Check to see whether a particular set of modules exists. Similar -# to PKG_CHECK_MODULES(), but does not set variables or print errors. -# -# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) -# only at the first occurence in configure.ac, so if the first place -# it's called might be skipped (such as if it is within an "if", you -# have to call PKG_CHECK_EXISTS manually -# -------------------------------------------------------------- +])dnl PKG_PROG_PKG_CONFIG + +dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +dnl ------------------------------------------------------------------- +dnl Since: 0.18 +dnl +dnl Check to see whether a particular set of modules exists. Similar to +dnl PKG_CHECK_MODULES(), but does not set variables or print errors. +dnl +dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +dnl only at the first occurence in configure.ac, so if the first place +dnl it's called might be skipped (such as if it is within an "if", you +dnl have to call PKG_CHECK_EXISTS manually AC_DEFUN([PKG_CHECK_EXISTS], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl if test -n "$PKG_CONFIG" && \ @@ -66,8 +98,10 @@ m4_ifvaln([$3], [else $3])dnl fi]) -# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) -# --------------------------------------------- +dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) +dnl --------------------------------------------- +dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting +dnl pkg_failed based on the result. m4_define([_PKG_CONFIG], [if test -n "$$1"; then pkg_cv_[]$1="$$1" @@ -79,10 +113,11 @@ m4_define([_PKG_CONFIG], else pkg_failed=untried fi[]dnl -])# _PKG_CONFIG +])dnl _PKG_CONFIG -# _PKG_SHORT_ERRORS_SUPPORTED -# ----------------------------- +dnl _PKG_SHORT_ERRORS_SUPPORTED +dnl --------------------------- +dnl Internal check to see if pkg-config supports short errors. AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], [AC_REQUIRE([PKG_PROG_PKG_CONFIG]) if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then @@ -90,26 +125,24 @@ if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then else _pkg_short_errors_supported=no fi[]dnl -])# _PKG_SHORT_ERRORS_SUPPORTED - - -# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], -# [ACTION-IF-NOT-FOUND]) -# -# -# Note that if there is a possibility the first call to -# PKG_CHECK_MODULES might not happen, you should be sure to include an -# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac -# -# -# -------------------------------------------------------------- +])dnl _PKG_SHORT_ERRORS_SUPPORTED + + +dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], +dnl [ACTION-IF-NOT-FOUND]) +dnl -------------------------------------------------------------- +dnl Since: 0.4.0 +dnl +dnl Note that if there is a possibility the first call to +dnl PKG_CHECK_MODULES might not happen, you should be sure to include an +dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac AC_DEFUN([PKG_CHECK_MODULES], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl pkg_failed=no -AC_MSG_CHECKING([for $1]) +AC_MSG_CHECKING([for $2]) _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) _PKG_CONFIG([$1][_LIBS], [libs], [$2]) @@ -119,7 +152,7 @@ and $1[]_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.]) if test $pkg_failed = yes; then - AC_MSG_RESULT([no]) + AC_MSG_RESULT([no]) _PKG_SHORT_ERRORS_SUPPORTED if test $_pkg_short_errors_supported = yes; then $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` @@ -140,7 +173,7 @@ installed software in a non-standard prefix. _PKG_TEXT])[]dnl ]) elif test $pkg_failed = untried; then - AC_MSG_RESULT([no]) + AC_MSG_RESULT([no]) m4_default([$4], [AC_MSG_FAILURE( [The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full @@ -156,16 +189,40 @@ else AC_MSG_RESULT([yes]) $3 fi[]dnl -])# PKG_CHECK_MODULES +])dnl PKG_CHECK_MODULES + + +dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], +dnl [ACTION-IF-NOT-FOUND]) +dnl --------------------------------------------------------------------- +dnl Since: 0.29 +dnl +dnl Checks for existence of MODULES and gathers its build flags with +dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags +dnl and VARIABLE-PREFIX_LIBS from --libs. +dnl +dnl Note that if there is a possibility the first call to +dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to +dnl include an explicit call to PKG_PROG_PKG_CONFIG in your +dnl configure.ac. +AC_DEFUN([PKG_CHECK_MODULES_STATIC], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +_save_PKG_CONFIG=$PKG_CONFIG +PKG_CONFIG="$PKG_CONFIG --static" +PKG_CHECK_MODULES($@) +PKG_CONFIG=$_save_PKG_CONFIG[]dnl +])dnl PKG_CHECK_MODULES_STATIC -# PKG_INSTALLDIR(DIRECTORY) -# ------------------------- -# Substitutes the variable pkgconfigdir as the location where a module -# should install pkg-config .pc files. By default the directory is -# $libdir/pkgconfig, but the default can be changed by passing -# DIRECTORY. The user can override through the --with-pkgconfigdir -# parameter. +dnl PKG_INSTALLDIR([DIRECTORY]) +dnl ------------------------- +dnl Since: 0.27 +dnl +dnl Substitutes the variable pkgconfigdir as the location where a module +dnl should install pkg-config .pc files. By default the directory is +dnl $libdir/pkgconfig, but the default can be changed by passing +dnl DIRECTORY. The user can override through the --with-pkgconfigdir +dnl parameter. AC_DEFUN([PKG_INSTALLDIR], [m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) m4_pushdef([pkg_description], @@ -176,16 +233,18 @@ AC_ARG_WITH([pkgconfigdir], AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) m4_popdef([pkg_default]) m4_popdef([pkg_description]) -]) dnl PKG_INSTALLDIR +])dnl PKG_INSTALLDIR -# PKG_NOARCH_INSTALLDIR(DIRECTORY) -# ------------------------- -# Substitutes the variable noarch_pkgconfigdir as the location where a -# module should install arch-independent pkg-config .pc files. By -# default the directory is $datadir/pkgconfig, but the default can be -# changed by passing DIRECTORY. The user can override through the -# --with-noarch-pkgconfigdir parameter. +dnl PKG_NOARCH_INSTALLDIR([DIRECTORY]) +dnl -------------------------------- +dnl Since: 0.27 +dnl +dnl Substitutes the variable noarch_pkgconfigdir as the location where a +dnl module should install arch-independent pkg-config .pc files. By +dnl default the directory is $datadir/pkgconfig, but the default can be +dnl changed by passing DIRECTORY. The user can override through the +dnl --with-noarch-pkgconfigdir parameter. AC_DEFUN([PKG_NOARCH_INSTALLDIR], [m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) m4_pushdef([pkg_description], @@ -196,13 +255,15 @@ AC_ARG_WITH([noarch-pkgconfigdir], AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) m4_popdef([pkg_default]) m4_popdef([pkg_description]) -]) dnl PKG_NOARCH_INSTALLDIR +])dnl PKG_NOARCH_INSTALLDIR -# PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, -# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) -# ------------------------------------------- -# Retrieves the value of the pkg-config variable for the given module. +dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, +dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +dnl ------------------------------------------- +dnl Since: 0.28 +dnl +dnl Retrieves the value of the pkg-config variable for the given module. AC_DEFUN([PKG_CHECK_VAR], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl @@ -211,4 +272,4 @@ _PKG_CONFIG([$1], [variable="][$3]["], [$2]) AS_VAR_COPY([$1], [pkg_cv_][$1]) AS_VAR_IF([$1], [""], [$5], [$4])dnl -])# PKG_CHECK_VAR +])dnl PKG_CHECK_VAR From 7d7f967d5e2b78da265d72ef2ceec541fa2b129d Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Thu, 29 Jul 2021 14:15:59 +0800 Subject: [PATCH 2/4] Detect incompatible libtorrent v2 versions in build systems Although the detection is working, the error message in autotools is not perfect, i.e. it would only mention valid range for libtorrent v1 and it shouldn't be a problem since v2 support isn't fully ready yet. --- CMakeLists.txt | 3 +- INSTALL | 12 +-- configure | 214 +++++++++++++++++++++++++++++++++++++++------ configure.ac | 8 +- src/CMakeLists.txt | 62 +++++++------ 5 files changed, 236 insertions(+), 63 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aa9fdefcf..909184245 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,8 @@ set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) set(minBoostVersion 1.65) set(minQtVersion 5.15.2) set(minOpenSSLVersion 1.1.1) -set(minLibtorrentVersion 1.2.14) +set(minLibtorrent1Version 1.2.14) +set(minLibtorrentVersion 2.0.4) set(minZlibVersion 1.2.11) # features (some are platform-specific) diff --git a/INSTALL b/INSTALL index 79639b390..3592bff17 100644 --- a/INSTALL +++ b/INSTALL @@ -5,8 +5,8 @@ qBittorrent - A BitTorrent client in C++ / Qt - Boost >= 1.65 - - libtorrent-rasterbar >= 1.2.14 (by Arvid Norberg) - * https://www.libtorrent.org/ + - libtorrent-rasterbar: (>= 1.2.14) || (>= 2.0.4) + * By Arvid Norberg, https://www.libtorrent.org/ * Be careful: another library (the one used by rTorrent) uses a similar name - OpenSSL >= 1.1.1 @@ -15,10 +15,12 @@ qBittorrent - A BitTorrent client in C++ / Qt - zlib >= 1.2.11 - - pkg-config (compile-time only on *nix systems) + - pkg-config + * Compile-time only on *nix systems - - Python >= 3.5.0 (optional, runtime only) - * Required by the internal search engine + - Python >= 3.5.0 + * Optional, run-time only + * Used by the bundled search engine Dependency version numbers are bumped every once in a while to keep the range of properly tested configurations manageable, even if not strictly required to build. You may be able to build with older versions of (some of) the dependencies other than the minimum versions specified in the build scripts, but support for such builds is not provided - you are on your own. diff --git a/configure b/configure index 91fa2a986..44110faa5 100755 --- a/configure +++ b/configure @@ -5522,8 +5522,8 @@ if test "x$enable_gui" = "xyes" then : pkg_failed=no -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Qt5Svg" >&5 -printf %s "checking for Qt5Svg... " >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Qt5Svg >= 5.15.2" >&5 +printf %s "checking for Qt5Svg >= 5.15.2... " >&6; } if test -n "$Qt5Svg_CFLAGS"; then pkg_cv_Qt5Svg_CFLAGS="$Qt5Svg_CFLAGS" @@ -5563,7 +5563,7 @@ fi if test $pkg_failed = yes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then @@ -5590,7 +5590,7 @@ Alternatively, you may set the environment variables Qt5Svg_CFLAGS and Qt5Svg_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} @@ -6032,19 +6032,19 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext pkg_failed=no -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libtorrent" >&5 -printf %s "checking for libtorrent... " >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libtorrent-rasterbar >= 2.0.4" >&5 +printf %s "checking for libtorrent-rasterbar >= 2.0.4... " >&6; } if test -n "$libtorrent_CFLAGS"; then pkg_cv_libtorrent_CFLAGS="$libtorrent_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libtorrent-rasterbar >= 1.2.14\""; } >&5 - ($PKG_CONFIG --exists --print-errors "libtorrent-rasterbar >= 1.2.14") 2>&5 + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libtorrent-rasterbar >= 2.0.4\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libtorrent-rasterbar >= 2.0.4") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_libtorrent_CFLAGS=`$PKG_CONFIG --cflags "libtorrent-rasterbar >= 1.2.14" 2>/dev/null` + pkg_cv_libtorrent_CFLAGS=`$PKG_CONFIG --cflags "libtorrent-rasterbar >= 2.0.4" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -6056,12 +6056,12 @@ if test -n "$libtorrent_LIBS"; then pkg_cv_libtorrent_LIBS="$libtorrent_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libtorrent-rasterbar >= 1.2.14\""; } >&5 - ($PKG_CONFIG --exists --print-errors "libtorrent-rasterbar >= 1.2.14") 2>&5 + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libtorrent-rasterbar >= 2.0.4\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libtorrent-rasterbar >= 2.0.4") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_libtorrent_LIBS=`$PKG_CONFIG --libs "libtorrent-rasterbar >= 1.2.14" 2>/dev/null` + pkg_cv_libtorrent_LIBS=`$PKG_CONFIG --libs "libtorrent-rasterbar >= 2.0.4" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -6073,7 +6073,7 @@ fi if test $pkg_failed = yes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then @@ -6082,14 +6082,167 @@ else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - libtorrent_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libtorrent-rasterbar >= 1.2.14" 2>&1` + libtorrent_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libtorrent-rasterbar >= 2.0.4" 2>&1` else - libtorrent_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libtorrent-rasterbar >= 1.2.14" 2>&1` + libtorrent_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libtorrent-rasterbar >= 2.0.4" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$libtorrent_PKG_ERRORS" >&5 - as_fn_error $? "Package requirements (libtorrent-rasterbar >= 1.2.14) were not met: + +pkg_failed=no +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libtorrent-rasterbar >= 1.2.14 libtorrent-rasterbar < 2" >&5 +printf %s "checking for libtorrent-rasterbar >= 1.2.14 libtorrent-rasterbar < 2... " >&6; } + +if test -n "$libtorrent_CFLAGS"; then + pkg_cv_libtorrent_CFLAGS="$libtorrent_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libtorrent-rasterbar >= 1.2.14 libtorrent-rasterbar < 2\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libtorrent-rasterbar >= 1.2.14 libtorrent-rasterbar < 2") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_libtorrent_CFLAGS=`$PKG_CONFIG --cflags "libtorrent-rasterbar >= 1.2.14 libtorrent-rasterbar < 2" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$libtorrent_LIBS"; then + pkg_cv_libtorrent_LIBS="$libtorrent_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libtorrent-rasterbar >= 1.2.14 libtorrent-rasterbar < 2\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libtorrent-rasterbar >= 1.2.14 libtorrent-rasterbar < 2") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_libtorrent_LIBS=`$PKG_CONFIG --libs "libtorrent-rasterbar >= 1.2.14 libtorrent-rasterbar < 2" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + libtorrent_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libtorrent-rasterbar >= 1.2.14 libtorrent-rasterbar < 2" 2>&1` + else + libtorrent_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libtorrent-rasterbar >= 1.2.14 libtorrent-rasterbar < 2" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$libtorrent_PKG_ERRORS" >&5 + + as_fn_error $? "Package requirements (libtorrent-rasterbar >= 1.2.14 libtorrent-rasterbar < 2) were not met: + +$libtorrent_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +Alternatively, you may set the environment variables libtorrent_CFLAGS +and libtorrent_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 +elif test $pkg_failed = untried; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +Alternatively, you may set the environment variables libtorrent_CFLAGS +and libtorrent_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. + +To get pkg-config, see . +See \`config.log' for more details" "$LINENO" 5; } +else + libtorrent_CFLAGS=$pkg_cv_libtorrent_CFLAGS + libtorrent_LIBS=$pkg_cv_libtorrent_LIBS + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + CXXFLAGS="$libtorrent_CFLAGS $CXXFLAGS" LIBS="$libtorrent_LIBS $LIBS" +fi +elif test $pkg_failed = untried; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + +pkg_failed=no +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libtorrent-rasterbar >= 1.2.14 libtorrent-rasterbar < 2" >&5 +printf %s "checking for libtorrent-rasterbar >= 1.2.14 libtorrent-rasterbar < 2... " >&6; } + +if test -n "$libtorrent_CFLAGS"; then + pkg_cv_libtorrent_CFLAGS="$libtorrent_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libtorrent-rasterbar >= 1.2.14 libtorrent-rasterbar < 2\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libtorrent-rasterbar >= 1.2.14 libtorrent-rasterbar < 2") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_libtorrent_CFLAGS=`$PKG_CONFIG --cflags "libtorrent-rasterbar >= 1.2.14 libtorrent-rasterbar < 2" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$libtorrent_LIBS"; then + pkg_cv_libtorrent_LIBS="$libtorrent_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libtorrent-rasterbar >= 1.2.14 libtorrent-rasterbar < 2\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libtorrent-rasterbar >= 1.2.14 libtorrent-rasterbar < 2") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_libtorrent_LIBS=`$PKG_CONFIG --libs "libtorrent-rasterbar >= 1.2.14 libtorrent-rasterbar < 2" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + libtorrent_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libtorrent-rasterbar >= 1.2.14 libtorrent-rasterbar < 2" 2>&1` + else + libtorrent_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libtorrent-rasterbar >= 1.2.14 libtorrent-rasterbar < 2" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$libtorrent_PKG_ERRORS" >&5 + + as_fn_error $? "Package requirements (libtorrent-rasterbar >= 1.2.14 libtorrent-rasterbar < 2) were not met: $libtorrent_PKG_ERRORS @@ -6100,7 +6253,7 @@ Alternatively, you may set the environment variables libtorrent_CFLAGS and libtorrent_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} @@ -6119,14 +6272,20 @@ else libtorrent_LIBS=$pkg_cv_libtorrent_LIBS { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 printf "%s\n" "yes" >&6; } - CXXFLAGS="$libtorrent_CFLAGS $CXXFLAGS" - LIBS="$libtorrent_LIBS $LIBS" + CXXFLAGS="$libtorrent_CFLAGS $CXXFLAGS" LIBS="$libtorrent_LIBS $LIBS" +fi +else + libtorrent_CFLAGS=$pkg_cv_libtorrent_CFLAGS + libtorrent_LIBS=$pkg_cv_libtorrent_LIBS + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + CXXFLAGS="$libtorrent_CFLAGS $CXXFLAGS" LIBS="$libtorrent_LIBS $LIBS" fi pkg_failed=no -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for openssl" >&5 -printf %s "checking for openssl... " >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for openssl >= 1.1.1" >&5 +printf %s "checking for openssl >= 1.1.1... " >&6; } if test -n "$openssl_CFLAGS"; then pkg_cv_openssl_CFLAGS="$openssl_CFLAGS" @@ -6166,7 +6325,7 @@ fi if test $pkg_failed = yes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then @@ -6193,7 +6352,7 @@ Alternatively, you may set the environment variables openssl_CFLAGS and openssl_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} @@ -6218,8 +6377,8 @@ fi pkg_failed=no -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for zlib" >&5 -printf %s "checking for zlib... " >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for zlib >= 1.2.11" >&5 +printf %s "checking for zlib >= 1.2.11... " >&6; } if test -n "$zlib_CFLAGS"; then pkg_cv_zlib_CFLAGS="$zlib_CFLAGS" @@ -6259,7 +6418,7 @@ fi if test $pkg_failed = yes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then @@ -6286,7 +6445,7 @@ Alternatively, you may set the environment variables zlib_CFLAGS and zlib_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} @@ -7845,3 +8004,4 @@ fi { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Good, the configure finished." >&5 printf "%s\n" "$as_me: Good, the configure finished." >&6;} printf "%s\n" + diff --git a/configure.ac b/configure.ac index 5c63b1df0..c8b97e9da 100644 --- a/configure.ac +++ b/configure.ac @@ -177,9 +177,11 @@ AC_COMPILE_IFELSE([DETECT_BOOST_VERSION_PROGRAM(106000)], [], [QBT_ADD_DEFINES="$QBT_ADD_DEFINES BOOST_NO_CXX11_RVALUE_REFERENCES"]) PKG_CHECK_MODULES(libtorrent, - [libtorrent-rasterbar >= 1.2.14], - [CXXFLAGS="$libtorrent_CFLAGS $CXXFLAGS" - LIBS="$libtorrent_LIBS $LIBS"]) + [libtorrent-rasterbar >= 2.0.4], + [CXXFLAGS="$libtorrent_CFLAGS $CXXFLAGS" LIBS="$libtorrent_LIBS $LIBS"], + [PKG_CHECK_MODULES(libtorrent, + [libtorrent-rasterbar >= 1.2.14 libtorrent-rasterbar < 2], + [CXXFLAGS="$libtorrent_CFLAGS $CXXFLAGS" LIBS="$libtorrent_LIBS $LIBS"])]) PKG_CHECK_MODULES(openssl, [openssl >= 1.1.1], diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 25c821090..d22c93a27 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,35 +1,43 @@ -if (UNIX AND (NOT APPLE) AND (NOT CYGWIN)) - find_package(LibtorrentRasterbar QUIET ${minLibtorrentVersion} COMPONENTS torrent-rasterbar) - if (NOT LibtorrentRasterbar_FOUND) - include(FindPkgConfig) - pkg_check_modules(LIBTORRENT_RASTERBAR IMPORTED_TARGET GLOBAL "libtorrent-rasterbar>=${minLibtorrentVersion}") - if (NOT LIBTORRENT_RASTERBAR_FOUND) - message( - FATAL_ERROR - "Package LibtorrentRasterbar >= ${minLibtorrentVersion} not found" - " with CMake or pkg-config.\n- Set LibtorrentRasterbar_DIR to a directory containing" - " a LibtorrentRasterbarConfig.cmake file or add the installation prefix of LibtorrentRasterbar" - " to CMAKE_PREFIX_PATH.\n- Alternatively, make sure there is a valid libtorrent-rasterbar.pc" - " file in your system's pkg-config search paths (use the system environment variable PKG_CONFIG_PATH" - " to specify additional search paths if needed)." +macro(find_libtorrent version) + if (UNIX AND (NOT APPLE) AND (NOT CYGWIN)) + find_package(LibtorrentRasterbar QUIET ${version} COMPONENTS torrent-rasterbar) + if (NOT LibtorrentRasterbar_FOUND) + include(FindPkgConfig) + pkg_check_modules(LibtorrentRasterbar IMPORTED_TARGET GLOBAL "libtorrent-rasterbar>=${version}") + if (NOT LibtorrentRasterbar_FOUND) + message( + FATAL_ERROR + "Package LibtorrentRasterbar >= ${version} not found" + " with CMake or pkg-config.\n- Set LibtorrentRasterbar_DIR to a directory containing" + " a LibtorrentRasterbarConfig.cmake file or add the installation prefix of LibtorrentRasterbar" + " to CMAKE_PREFIX_PATH.\n- Alternatively, make sure there is a valid libtorrent-rasterbar.pc" + " file in your system's pkg-config search paths (use the system environment variable PKG_CONFIG_PATH" + " to specify additional search paths if needed)." + ) + endif() + add_library(LibtorrentRasterbar::torrent-rasterbar ALIAS PkgConfig::LibtorrentRasterbar) + # force a fake package to show up in the feature summary + set_property(GLOBAL APPEND PROPERTY + PACKAGES_FOUND + "LibtorrentRasterbar via pkg-config (version >= ${version})" ) + set_package_properties("LibtorrentRasterbar via pkg-config (version >= ${version})" + PROPERTIES + TYPE REQUIRED + ) + else() + set_package_properties(LibtorrentRasterbar PROPERTIES TYPE REQUIRED) endif() - add_library(LibtorrentRasterbar::torrent-rasterbar ALIAS PkgConfig::LIBTORRENT_RASTERBAR) - # force a fake package to show up in the feature summary - set_property(GLOBAL APPEND PROPERTY - PACKAGES_FOUND - "LibtorrentRasterbar via pkg-config (version >= ${minLibtorrentVersion})" - ) - set_package_properties("LibtorrentRasterbar via pkg-config (version >= ${minLibtorrentVersion})" - PROPERTIES - TYPE REQUIRED - ) else() - set_package_properties(LibtorrentRasterbar PROPERTIES TYPE REQUIRED) + find_package(LibtorrentRasterbar ${version} REQUIRED COMPONENTS torrent-rasterbar) endif() -else() - find_package(LibtorrentRasterbar ${minLibtorrentVersion} REQUIRED COMPONENTS torrent-rasterbar) +endmacro() + +find_libtorrent(${minLibtorrent1Version}) +if (LibtorrentRasterbar_FOUND AND (LibtorrentRasterbar_VERSION VERSION_GREATER_EQUAL 2.0)) + find_libtorrent(${minLibtorrentVersion}) endif() + # force variable type so that it always shows up in ccmake/cmake-gui frontends set_property(CACHE LibtorrentRasterbar_DIR PROPERTY TYPE PATH) find_package(Boost ${minBoostVersion} REQUIRED) From 3d94c70c4802612ebf2f3bec6f5496fd0f69864c Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Thu, 29 Jul 2021 14:48:28 +0800 Subject: [PATCH 3/4] Adopt a subset of semantic versioning notation https://github.com/npm/node-semver#ranges https://semver.npmjs.com/ --- INSTALL | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/INSTALL b/INSTALL index 3592bff17..0b0809b6b 100644 --- a/INSTALL +++ b/INSTALL @@ -5,17 +5,17 @@ qBittorrent - A BitTorrent client in C++ / Qt - Boost >= 1.65 - - libtorrent-rasterbar: (>= 1.2.14) || (>= 2.0.4) + - libtorrent-rasterbar 1.2.14 - 1.2.x || 2.0.4 - 2.0.x * By Arvid Norberg, https://www.libtorrent.org/ * Be careful: another library (the one used by rTorrent) uses a similar name - OpenSSL >= 1.1.1 - - Qt >= 5.15.2 + - Qt 5.15.2 - 5.x - zlib >= 1.2.11 - - pkg-config + - pkg-config * * Compile-time only on *nix systems - Python >= 3.5.0 From 0a1865d0ddc94ddfc44e2c9370a28e638cd8bc68 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 28 Jul 2021 17:35:47 +0800 Subject: [PATCH 4/4] Don't use old style cast --- src/app/qtlocalpeer/qtlockedfile_win.cpp | 4 ++-- src/app/stacktrace_win.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/app/qtlocalpeer/qtlockedfile_win.cpp b/src/app/qtlocalpeer/qtlockedfile_win.cpp index 004194aaf..75848ad73 100644 --- a/src/app/qtlocalpeer/qtlockedfile_win.cpp +++ b/src/app/qtlocalpeer/qtlockedfile_win.cpp @@ -89,7 +89,7 @@ Qt::HANDLE QtLockedFile::getMutexHandle(int idx, bool doCreate) Qt::HANDLE mutex; if (doCreate) { - QT_WA( { mutex = CreateMutexW(NULL, FALSE, (TCHAR*)mname.utf16()); }, + QT_WA( { mutex = CreateMutexW(NULL, FALSE, reinterpret_cast(mname.utf16())); }, { mutex = CreateMutexA(NULL, FALSE, mname.toLocal8Bit().constData()); } ); if (!mutex) { qErrnoWarning("QtLockedFile::lock(): CreateMutex failed"); @@ -97,7 +97,7 @@ Qt::HANDLE QtLockedFile::getMutexHandle(int idx, bool doCreate) } } else { - QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (TCHAR*)mname.utf16()); }, + QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, reinterpret_cast(mname.utf16())); }, { mutex = OpenMutexA(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, mname.toLocal8Bit().constData()); } ); if (!mutex) { if (GetLastError() != ERROR_FILE_NOT_FOUND) diff --git a/src/app/stacktrace_win.h b/src/app/stacktrace_win.h index 7c92fba1e..7a92d54b1 100644 --- a/src/app/stacktrace_win.h +++ b/src/app/stacktrace_win.h @@ -73,7 +73,7 @@ void straceWin::loadHelpStackFrame(IMAGEHLP_STACK_FRAME& ihsf, const STACKFRAME6 BOOL CALLBACK straceWin::EnumSymbolsCB(PSYMBOL_INFO symInfo, ULONG size, PVOID user) { Q_UNUSED(size) - QStringList* params = (QStringList*)user; + auto params = static_cast(user); if (symInfo->Flags & SYMFLAG_PARAMETER) params->append(symInfo->Name); return TRUE; @@ -91,7 +91,7 @@ BOOL CALLBACK straceWin::EnumModulesCB(LPCSTR ModuleName, DWORD64 BaseOfDll, PVO { Q_UNUSED(ModuleName) IMAGEHLP_MODULE64 mod; - EnumModulesContext* context = (EnumModulesContext*)UserContext; + auto context = static_cast(UserContext); mod.SizeOfStruct = sizeof(IMAGEHLP_MODULE64); if(SymGetModuleInfo64(context->hProcess, BaseOfDll, &mod)) { @@ -264,7 +264,7 @@ const QString straceWin::getBacktrace() ULONG64 buffer[(sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR) + sizeof(ULONG64) - 1) / sizeof(ULONG64)]; - PSYMBOL_INFO pSymbol = (PSYMBOL_INFO)buffer; + auto pSymbol = reinterpret_cast(buffer); pSymbol->SizeOfStruct = sizeof(SYMBOL_INFO); pSymbol->MaxNameLen = MAX_SYM_NAME;