add_library(Core STATIC
    application.h
    application.cpp
    applicationsingleton.h
    applicationsingleton.cpp
    extractor.h
    extractor.cpp
    filemanager.h
    filemanager.cpp
    httpserver.h
    httpserver.cpp
    networkaccessmanager.h
    networkaccessmanager.cpp
    settings.h
    settings.cpp
    global.h
    global.cpp
    httplib.h
)

add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")

# Configure cpp-httplib.
add_definitions(-DCPPHTTPLIB_USE_POLL)

target_link_libraries(Core Registry Ui)

find_package(Qt5 COMPONENTS Network WebEngine Widgets REQUIRED)
target_link_libraries(Core Qt5::Network Qt5::WebEngine Qt5::Widgets)

set(LibArchive_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../../../dependencies/libarchive/include")
target_link_directories(Core PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../../../dependencies/libarchive/lib")
set(LibArchive_LIBRARIES archive.lib)

#find_package(LibArchive REQUIRED)
include_directories(${LibArchive_INCLUDE_DIRS})
target_link_libraries(Core ${LibArchive_LIBRARIES})

# Required by cpp-httplib.
if(NOT WIN32)
    set(THREADS_PREFER_PTHREAD_FLAG ON)
    find_package(Threads REQUIRED)
    target_link_libraries(Core Threads::Threads)
endif()
