cmake_minimum_required(VERSION 3.20)
project(SecondVoice_NoUI VERSION 0.1.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Find packages (NO IMGUI, NO GLFW, NO OPENGL)
find_package(portaudio CONFIG REQUIRED)
find_package(httplib CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)

# Source files (NO UI)
set(SOURCES
    src/main_no_ui_test.cpp
    src/audio/AudioCapture.cpp
    src/audio/AudioBuffer.cpp
    src/utils/Config.cpp
)

# Executable
add_executable(${PROJECT_NAME} ${SOURCES})

# Include directories
target_include_directories(${PROJECT_NAME} PRIVATE
    ${CMAKE_CURRENT_SOURCE_DIR}/src
)

# Link libraries (NO IMGUI)
target_link_libraries(${PROJECT_NAME} PRIVATE
    portaudio
    httplib::httplib
    nlohmann_json::nlohmann_json
)

# Compiler options
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
    target_compile_options(${PROJECT_NAME} PRIVATE
        -Wall
        -Wextra
        -Wpedantic
    )

    if(MINGW)
        target_link_options(${PROJECT_NAME} PRIVATE -mconsole)
    endif()
endif()

# Copy config files to build directory
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.json
               ${CMAKE_CURRENT_BINARY_DIR}/config.json COPYONLY)
