# TODO: repo with dependencies, ExternalProject_Add(), FetchContent

add_subdirectory(spdlog-1.12.0)
add_subdirectory(restbed-4.8)

include(ExternalProject)
ExternalProject_Add(project_botan
    SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Botan-3.2.0
    PREFIX ${CMAKE_CURRENT_BINARY_DIR}/botan
    CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/Botan-3.2.0/configure.py --with-build-dir=<BINARY_DIR> --prefix=<INSTALL_DIR> --disable-shared --minimized-build --build-targets=static --without-sphinx --without-rst2man --enable-modules=argon2fmt,hotp,base32,auto_rng,system_rng,tls13,certstor_system,certstor_flatfile,md5
    BUILD_COMMAND make -j libs
    BUILD_BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/botan/lib/libbotan-3.a"
    INSTALL_COMMAND make install
    USES_TERMINAL_BUILD YES
    USES_TERMINAL_INSTALL YES
)
add_library(botan INTERFACE IMPORTED)
target_link_libraries(botan INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/botan/lib/libbotan-3.a")
target_include_directories(botan INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/botan/include/botan-3")
add_dependencies(botan project_botan)

add_library(miniz STATIC miniz/miniz.c miniz/miniz.h)
target_include_directories(miniz PUBLIC miniz)

add_library(${PROJECT_NAME}_libs INTERFACE)
target_link_libraries(${PROJECT_NAME}_libs INTERFACE
    spdlog::spdlog
    restbed-static
    botan
    miniz
)
target_include_directories(${PROJECT_NAME}_libs INTERFACE restbed-4.8/dependency/asio/asio/include Botan-3.2.0)
