find_package(ZLIB 1.2.5.2 REQUIRED)

add_library(qbt_base STATIC
    # headers
    algorithm.h
    asyncfilestorage.h
    bittorrent/addtorrentparams.h
    bittorrent/bandwidthscheduler.h
    bittorrent/cachestatus.h
    bittorrent/downloadpriority.h
    bittorrent/filterparserthread.h
    bittorrent/infohash.h
    bittorrent/ltunderlyingtype.h
    bittorrent/magneturi.h
    bittorrent/nativesessionextension.h
    bittorrent/nativetorrentextension.h
    bittorrent/peeraddress.h
    bittorrent/peerinfo.h
    bittorrent/portforwarderimpl.h
    bittorrent/resumedatasavingmanager.h
    bittorrent/session.h
    bittorrent/sessionstatus.h
    bittorrent/speedmonitor.h
    bittorrent/statistics.h
    bittorrent/torrentcreatorthread.h
    bittorrent/torrenthandle.h
    bittorrent/torrenthandleimpl.h
    bittorrent/torrentinfo.h
    bittorrent/tracker.h
    bittorrent/trackerentry.h
    exceptions.h
    filesystemwatcher.h
    global.h
    http/connection.h
    http/httperror.h
    http/irequesthandler.h
    http/requestparser.h
    http/responsebuilder.h
    http/responsegenerator.h
    http/server.h
    http/types.h
    iconprovider.h
    indexrange.h
    logger.h
    net/dnsupdater.h
    net/downloadhandlerimpl.h
    net/downloadmanager.h
    net/geoipdatabase.h
    net/geoipmanager.h
    net/portforwarder.h
    net/proxyconfigurationmanager.h
    net/reverseresolution.h
    net/smtp.h
    preferences.h
    profile.h
    profile_p.h
    rss/rss_article.h
    rss/rss_autodownloader.h
    rss/rss_autodownloadrule.h
    rss/rss_feed.h
    rss/rss_folder.h
    rss/rss_item.h
    rss/rss_parser.h
    rss/rss_session.h
    scanfoldersmodel.h
    search/searchdownloadhandler.h
    search/searchhandler.h
    search/searchpluginmanager.h
    settingsstorage.h
    torrentfileguard.h
    torrentfilter.h
    tristatebool.h
    types.h
    unicodestrings.h
    utils/bytearray.h
    utils/foreignapps.h
    utils/fs.h
    utils/gzip.h
    utils/io.h
    utils/misc.h
    utils/net.h
    utils/password.h
    utils/random.h
    utils/string.h
    utils/version.h

    # sources
    asyncfilestorage.cpp
    bittorrent/bandwidthscheduler.cpp
    bittorrent/downloadpriority.cpp
    bittorrent/filterparserthread.cpp
    bittorrent/infohash.cpp
    bittorrent/magneturi.cpp
    bittorrent/nativesessionextension.cpp
    bittorrent/nativetorrentextension.cpp
    bittorrent/peeraddress.cpp
    bittorrent/peerinfo.cpp
    bittorrent/portforwarderimpl.cpp
    bittorrent/resumedatasavingmanager.cpp
    bittorrent/session.cpp
    bittorrent/speedmonitor.cpp
    bittorrent/statistics.cpp
    bittorrent/torrentcreatorthread.cpp
    bittorrent/torrenthandle.cpp
    bittorrent/torrenthandleimpl.cpp
    bittorrent/torrentinfo.cpp
    bittorrent/tracker.cpp
    bittorrent/trackerentry.cpp
    exceptions.cpp
    filesystemwatcher.cpp
    http/connection.cpp
    http/httperror.cpp
    http/requestparser.cpp
    http/responsebuilder.cpp
    http/responsegenerator.cpp
    http/server.cpp
    iconprovider.cpp
    logger.cpp
    net/dnsupdater.cpp
    net/downloadhandlerimpl.cpp
    net/downloadmanager.cpp
    net/geoipdatabase.cpp
    net/geoipmanager.cpp
    net/portforwarder.cpp
    net/proxyconfigurationmanager.cpp
    net/reverseresolution.cpp
    net/smtp.cpp
    preferences.cpp
    profile.cpp
    profile_p.cpp
    rss/rss_article.cpp
    rss/rss_autodownloader.cpp
    rss/rss_autodownloadrule.cpp
    rss/rss_feed.cpp
    rss/rss_folder.cpp
    rss/rss_item.cpp
    rss/rss_parser.cpp
    rss/rss_session.cpp
    scanfoldersmodel.cpp
    search/searchdownloadhandler.cpp
    search/searchhandler.cpp
    search/searchpluginmanager.cpp
    settingsstorage.cpp
    torrentfileguard.cpp
    torrentfilter.cpp
    tristatebool.cpp
    utils/bytearray.cpp
    utils/foreignapps.cpp
    utils/fs.cpp
    utils/gzip.cpp
    utils/io.cpp
    utils/misc.cpp
    utils/net.cpp
    utils/password.cpp
    utils/random.cpp
    utils/string.cpp
)

target_link_libraries(qbt_base
    PRIVATE
        ZLIB::ZLIB
    PUBLIC
        LibtorrentRasterbar::torrent-rasterbar
        Qt5::Core Qt5::Network Qt5::Xml
)

if (Qt5DBus_FOUND)
    target_link_libraries(qbt_base PRIVATE Qt5::DBus)
endif()

if (APPLE)
    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})
endif()
