# libveloxcore — the download engine. Lane CORE.
#
# No JSON, no SQL, no Qt, no RPC in this tree (CLAUDE.md §3, AGENT-CORE brief).
# This file is self-contained; it is wired into the build by PKG uncommenting
# `add_subdirectory(core)` in the root CMakeLists.txt (see core/docs/pkg-requests-m1.md).

find_package(Threads REQUIRED)
find_package(CURL 8.0 REQUIRED)

add_library(veloxcore STATIC
    src/util/error.cpp
    src/util/log.cpp
    src/util/thread_pool.cpp
    src/net/curl_error.cpp
    src/net/http_client.cpp
    src/net/text_codec.cpp
    src/net/content_disposition.cpp
    src/net/url.cpp
    src/net/probe.cpp
)
add_library(velox::core ALIAS veloxcore)

target_include_directories(veloxcore
    PUBLIC  ${CMAKE_CURRENT_SOURCE_DIR}/include
    PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src   # net/*.cpp -> "net/curl_error.hpp"
)

target_compile_features(veloxcore PUBLIC cxx_std_23)

# Warnings are set at target scope, not via CMAKE_CXX_FLAGS: the dev/tsan presets
# overwrite that cache variable wholesale (see core/docs/pkg-requests-m1.md P4).
target_compile_options(veloxcore PRIVATE
    -Wall -Wextra -Wpedantic -Werror
)

target_link_libraries(veloxcore PUBLIC Threads::Threads CURL::libcurl)

# Later stages add: find_package(OpenSSL) for meta/ (streaming SHA-256 + resume CRC).

if(VELOX_BUILD_TESTS)
    add_subdirectory(tests)
endif()

# Fuzz targets live in ${CMAKE_SOURCE_DIR}/tools/fuzz (lane CORE) and are wired in by the
# top-level CMakeLists.txt, which add_subdirectory()s every tools/* with a CMakeLists.
# tools/fuzz/CMakeLists.txt self-guards on VELOX_BUILD_FUZZ + a Clang compiler.
# Present: Content-Disposition, URL (stage 3). Coming: .veloxpart.meta (stage 5).
