add_library(vectorapi_core STATIC
    config.cpp
    errors.cpp
    json_http.cpp
    filters.cpp
    db_gateway.cpp
    settings.cpp
    apikey.cpp
    key_store.cpp
    settings_store.cpp
    collection_registry.cpp
    embeddings.cpp
    embedding_cache.cpp
    auth.cpp
    server.cpp
    handlers/meta.cpp
    handlers/webui_auth.cpp
    handlers/projects.cpp
    handlers/keys.cpp
    handlers/collections.cpp
    handlers/documents.cpp
    handlers/vectors.cpp
    handlers/stats.cpp
    handlers/settings.cpp
)
target_include_directories(vectorapi_core PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}
    ${CMAKE_BINARY_DIR}/generated)
target_link_libraries(vectorapi_core PUBLIC
    smartbotic::db-client
    httplib::httplib
    nlohmann_json::nlohmann_json
    spdlog::spdlog
    OpenSSL::SSL OpenSSL::Crypto)
target_compile_definitions(vectorapi_core PUBLIC CPPHTTPLIB_OPENSSL_SUPPORT)

add_executable(smartbotic-vectorapi main.cpp)
target_link_libraries(smartbotic-vectorapi PRIVATE
    vectorapi_core
    $<$<BOOL:${SYSTEMD_FOUND}>:PkgConfig::SYSTEMD>)
if(SYSTEMD_FOUND)
    target_compile_definitions(smartbotic-vectorapi PRIVATE HAVE_SYSTEMD)
endif()
install(TARGETS smartbotic-vectorapi RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
