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)