CMake: overhaul and improve scripts

- Bump minimum required version and
make use of more modern language features
- Rely more on target_...() commands to establish dependency
relationships between targets rather than directory property commands
- Improve libtorrent package discovery
- Enable and handle application features more explicitly
- Improve user-facing output
- Fix various compilation issues on Windows (MSVC and MinGW) and macOS
- Improve handling of translations
- Add explanatory comments where relevant
- Make CMake scripts fully independent of qmake files/details
- Remove old functions/macros
This commit is contained in:
FranciscoPombal
2020-05-03 19:28:07 +01:00
parent 79bc4f40e8
commit 46123b9989
28 changed files with 474 additions and 1239 deletions

View File

@@ -1,5 +1,3 @@
find_package(ZLIB 1.2.5.2 REQUIRED)
add_library(qbt_base STATIC
# headers
algorithm.h
@@ -162,18 +160,35 @@ add_library(qbt_base STATIC
target_link_libraries(qbt_base
PRIVATE
ZLIB::ZLIB
qbt_version_definitions
PUBLIC
LibtorrentRasterbar::torrent-rasterbar
Qt5::Core Qt5::Network Qt5::Xml
qbt_common_cfg
)
if (Qt5DBus_FOUND)
target_link_libraries(qbt_base PRIVATE Qt5::DBus)
endif()
if (APPLE)
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
find_library(IOKit_LIBRARY IOKit)
find_library(Carbon_LIBRARY Carbon)
find_library(AppKit_LIBRARY AppKit)
target_link_libraries(qbt_base PRIVATE ${Carbon_LIBRARY} ${IOKit_LIBRARY} ${AppKit_LIBRARY})
target_link_libraries(qbt_base PRIVATE
${AppKit_LIBRARY}
${Carbon_LIBRARY}
${IOKit_LIBRARY}
)
elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
target_link_libraries(qbt_base PRIVATE Iphlpapi)
endif()
if (NOT GUI)
target_compile_definitions(qbt_base PUBLIC DISABLE_GUI)
endif()
if (NOT WEBUI)
target_compile_definitions(qbt_base PUBLIC DISABLE_WEBUI)
endif()
if (DBUS)
target_link_libraries(qbt_base PUBLIC Qt5::DBus)
endif()