From 473e23f992cd2557c1fd7d5e4dbfc08d9bb1f1a8 Mon Sep 17 00:00:00 2001 From: Eugene Shalygin Date: Mon, 18 Apr 2016 21:23:03 +0200 Subject: [PATCH 1/3] cmake: add imported target for Libtorrent --- cmake/Modules/FindLibtorrentRasterbar.cmake | 12 ++++++++++++ src/CMakeLists.txt | 2 -- src/base/CMakeLists.txt | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cmake/Modules/FindLibtorrentRasterbar.cmake b/cmake/Modules/FindLibtorrentRasterbar.cmake index f1ece1be4..1f09f2d95 100644 --- a/cmake/Modules/FindLibtorrentRasterbar.cmake +++ b/cmake/Modules/FindLibtorrentRasterbar.cmake @@ -91,3 +91,15 @@ find_package_handle_standard_args(LibtorrentRasterbar DEFAULT_MSG mark_as_advanced(LibtorrentRasterbar_INCLUDE_DIR LibtorrentRasterbar_LIBRARY LibtorrentRasterbar_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES LibtorrentRasterbar_ENCRYPTION_INDEX) + +if (LibtorrentRasterbar_FOUND AND NOT TARGET LibtorrentRasterbar::LibTorrent) + add_library(LibtorrentRasterbar::LibTorrent UNKNOWN IMPORTED) + + set_target_properties(LibtorrentRasterbar::LibTorrent PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${LibtorrentRasterbar_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${LibtorrentRasterbar_INCLUDE_DIRS}" + INTERFACE_LINK_LIBRARIES "${LibtorrentRasterbar_LIBRARIES}" + INTERFACE_COMPILE_OPTIONS "${LibtorrentRasterbar_DEFINITIONS}" + ) +endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 196871230..bafdbb717 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,8 +6,6 @@ include(MacroLinkQtComponents) include(QbtTargetSources) find_package(LibtorrentRasterbar REQUIRED) -include_directories(SYSTEM ${LibtorrentRasterbar_INCLUDE_DIRS}) -add_compile_options(${LibtorrentRasterbar_DEFINITIONS}) # Boost set(Boost_USE_MULTITHREADED ON) diff --git a/src/base/CMakeLists.txt b/src/base/CMakeLists.txt index ecf7c2533..2cde01244 100644 --- a/src/base/CMakeLists.txt +++ b/src/base/CMakeLists.txt @@ -113,7 +113,7 @@ tristatebool.cpp ) add_library(qbt_base STATIC ${QBT_BASE_HEADERS} ${QBT_BASE_SOURCES}) -target_link_libraries(qbt_base ${ZLIB_LIBRARIES} ${LibtorrentRasterbar_LIBRARIES}) +target_link_libraries(qbt_base ${ZLIB_LIBRARIES} LibtorrentRasterbar::LibTorrent) target_link_qt_components(qbt_base Core Network Xml) if (QT4_FOUND) if (GUI) From 8b64dd95a594b66a5ce8c1f7234311e374af7710 Mon Sep 17 00:00:00 2001 From: Eugene Shalygin Date: Mon, 18 Apr 2016 22:39:07 +0200 Subject: [PATCH 2/3] cmake: drop explicit Boost dependency We get it implicitly from libtorrent --- src/CMakeLists.txt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bafdbb717..bf3922325 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,11 +7,6 @@ include(QbtTargetSources) find_package(LibtorrentRasterbar REQUIRED) -# Boost -set(Boost_USE_MULTITHREADED ON) -find_package(Boost 1.35 REQUIRED COMPONENTS system) -include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) - # Qt if (QT5) add_definitions(-DQBT_USES_QT5) From 3f53f17411f3a2646bdc40f7e0809d7cec5e6735 Mon Sep 17 00:00:00 2001 From: Eugene Shalygin Date: Mon, 18 Apr 2016 22:40:22 +0200 Subject: [PATCH 3/3] cmake: raise minimal cmake version to 3.5 and use its features --- CMakeLists.txt | 4 ++-- src/base/CMakeLists.txt | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eff858410..a049e0677 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 3.2) -cmake_policy(VERSION 3.2) +cmake_minimum_required(VERSION 3.5) +cmake_policy(VERSION 3.5) project(qBittorrent VERSION 3.4.0.0) diff --git a/src/base/CMakeLists.txt b/src/base/CMakeLists.txt index 2cde01244..e3cc374a8 100644 --- a/src/base/CMakeLists.txt +++ b/src/base/CMakeLists.txt @@ -1,5 +1,4 @@ find_package(ZLIB REQUIRED) -include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS}) set(QBT_BASE_HEADERS bittorrent/cachestatus.h @@ -113,7 +112,7 @@ tristatebool.cpp ) add_library(qbt_base STATIC ${QBT_BASE_HEADERS} ${QBT_BASE_SOURCES}) -target_link_libraries(qbt_base ${ZLIB_LIBRARIES} LibtorrentRasterbar::LibTorrent) +target_link_libraries(qbt_base ZLIB::ZLIB LibtorrentRasterbar::LibTorrent) target_link_qt_components(qbt_base Core Network Xml) if (QT4_FOUND) if (GUI)