cmake_minimum_required(VERSION 3.20)

project(QtDesktopPetInternalQA LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_AUTOMOC OFF)

get_filename_component(DEFAULT_PET_SOURCE_ROOT "${CMAKE_CURRENT_LIST_DIR}/../.." ABSOLUTE)
set(PET_SOURCE_ROOT "${DEFAULT_PET_SOURCE_ROOT}" CACHE PATH "QtDesktopPet source root")

if (NOT EXISTS "${PET_SOURCE_ROOT}/src" OR NOT EXISTS "${PET_SOURCE_ROOT}/CMakeLists.txt")
    message(FATAL_ERROR "PET_SOURCE_ROOT does not point to a QtDesktopPet source tree: ${PET_SOURCE_ROOT}")
endif()

find_package(Qt6 REQUIRED COMPONENTS Core)

add_executable(QtDesktopPetCoreTests
    include/TestHarness.h
    tests/TestMain.cpp
    tests/assistant/IntentRoutingTests.cpp
    tests/reminder/ReminderTests.cpp
    tests/weather/WeatherTests.cpp
    tests/web/WebCapabilityTests.cpp
    tests/ai/ConversationStoreTests.cpp
    ${PET_SOURCE_ROOT}/src/assistant/IntentRouter.h
    ${PET_SOURCE_ROOT}/src/assistant/IntentRouter.cpp
    ${PET_SOURCE_ROOT}/src/assistant/CommandDispatcher.h
    ${PET_SOURCE_ROOT}/src/assistant/CommandDispatcher.cpp
    ${PET_SOURCE_ROOT}/src/assistant/UserIntent.h
    ${PET_SOURCE_ROOT}/src/reminder/ReminderParser.h
    ${PET_SOURCE_ROOT}/src/reminder/ReminderParser.cpp
    ${PET_SOURCE_ROOT}/src/reminder/ReminderTypes.h
    ${PET_SOURCE_ROOT}/src/reminder/ReminderTypes.cpp
    ${PET_SOURCE_ROOT}/src/weather/WeatherParser.h
    ${PET_SOURCE_ROOT}/src/weather/WeatherParser.cpp
    ${PET_SOURCE_ROOT}/src/weather/WeatherSummaryFormatter.h
    ${PET_SOURCE_ROOT}/src/weather/WeatherSummaryFormatter.cpp
    ${PET_SOURCE_ROOT}/src/weather/WeatherTypes.h
    ${PET_SOURCE_ROOT}/src/weather/WeatherConfig.h
    ${PET_SOURCE_ROOT}/src/web/WebCapabilityDetector.h
    ${PET_SOURCE_ROOT}/src/web/WebCapabilityDetector.cpp
    ${PET_SOURCE_ROOT}/src/web/WebChatTypes.h
    ${PET_SOURCE_ROOT}/src/web/WebConfig.h
    ${PET_SOURCE_ROOT}/src/config/AIConfig.h
    ${PET_SOURCE_ROOT}/src/config/AIConfig.cpp
    ${PET_SOURCE_ROOT}/src/ai/ConversationStore.h
    ${PET_SOURCE_ROOT}/src/ai/ConversationStore.cpp
    ${PET_SOURCE_ROOT}/src/ai/LLMTypes.h
    ${PET_SOURCE_ROOT}/src/util/Logger.h
    ${PET_SOURCE_ROOT}/src/util/Logger.cpp
)

target_include_directories(QtDesktopPetCoreTests
    PRIVATE
        "${CMAKE_CURRENT_LIST_DIR}/include"
        "${PET_SOURCE_ROOT}"
)

target_link_libraries(QtDesktopPetCoreTests PRIVATE Qt6::Core)

include(CTest)
add_test(NAME QtDesktopPetCoreTests COMMAND QtDesktopPetCoreTests)
