# CMakeLists.txt for frmlunarcalendarwidget unit tests
cmake_minimum_required(VERSION 3.5.0)
project(test_frmlunarcalendarwidget)

# Set C++ standard
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Enable Qt features
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)

# Find required packages
find_package(Qt5 COMPONENTS Core Widgets Test Sql DBus REQUIRED)

find_package(KF5WindowSystem REQUIRED)

# Add compile definitions for translation directory
set(PACKAGE_DATA_DIR "/usr/share/calendar")
set(CALENDAR_TRANSLATION_DIR "${PACKAGE_DATA_DIR}/plugin-calendar/translation")
add_compile_definitions(CALENDAR_TRANSLATION_DIR="${CALENDAR_TRANSLATION_DIR}")

# Find gsettings-qt
find_package(PkgConfig REQUIRED)
pkg_check_modules(Gsetting REQUIRED gsettings-qt)
pkg_check_modules(KYSDK_SYSTIME REQUIRED kysdk-systime)
pkg_check_modules(KYSDK_KABASE REQUIRED kysdk-kabase)
pkg_check_modules(KYSDKQTWIDGETS REQUIRED kysdk-qtwidgets)
pkg_check_modules(KYSDKWAYLANDHELPER REQUIRED kysdk-waylandhelper)
pkg_check_modules(KYSDK_DATACOLLECT REQUIRED kysdk-datacollect)
pkg_check_modules(KYSDK_UKUIWINDOWHELPER REQUIRED kysdk-ukuiwindowhelper)
pkg_check_modules(CALENDAR_DEPS REQUIRED glib-2.0)

# Include directories
include_directories(
    ../../../lunarcalendarwidget
    ${Qt5Core_INCLUDE_DIRS}
    ${Qt5Widgets_INCLUDE_DIRS}
    ${GTEST_INCLUDE_DIRS}
    ${Qt5DBus_INCLUDE_DIRS}
    ${Gsetting_INCLUDE_DIRS}
    ${KYSDK_SYSTIME_INCLUDE_DIRS}
    ${KYSDK_KABASE_INCLUDE_DIRS}
    ${KYSDK_DATACOLLECT_INCLUDE_DIRS}
    ${KYSDKQTWIDGETS_INCLUDE_DIRS}
    ${KYSDK_UKUIWINDOWHELPER_INCLUDE_DIRS}
    ${KYSDKWAYLANDHELPER_INCLUDE_DIRS}
    ${CALENDAR_DEPS_INCLUDE_DIRS}
    /usr/include/kysdk/applications
    /usr/include/kysdk/kysdk-system
)

# Source files for test
set(TEST_SOURCES
    test_frmlunarcalendarwidget.cpp
    main.cpp
    ../../../lunarcalendarwidget/frmlunarcalendarwidget.cpp
    ../../../lunarcalendarwidget/lunarcalendarwidget.cpp
    ../../../lunarcalendarwidget/notificationsadaptor.cpp
    ../../../lunarcalendarwidget/calendardatabase.cpp
    ../../../lunarcalendarwidget/custommessagebox.cpp
    ../../../lunarcalendarwidget/schedule_item.cpp
    ../../../lunarcalendarwidget/schedulewidget.cpp
    ../../../lunarcalendarwidget/lunarcalendarinfo.cpp
    ../../../lunarcalendarwidget/lunarcalendaritem.cpp
    ../../../lunarcalendarwidget/customscrollarea.cpp
    ../../../lunarcalendarwidget/colorarea.cpp
    ../../../lunarcalendarwidget/lunarcalendaryearitem.cpp
    ../../../lunarcalendarwidget/lunarcalendarmonthitem.cpp
    ../../../lunarcalendarwidget/calendarcolor.cpp
)

# Create test executable
add_executable(test_frmlunarcalendarwidget ${TEST_SOURCES})

# Link libraries
target_link_libraries(test_frmlunarcalendarwidget PRIVATE
    Qt5::Core
    Qt5::Widgets
    Qt5::Sql
    KF5::WindowSystem
    Qt5::Test
    Qt5::DBus
    ${Gsetting_LIBRARIES}
    ${KYSDK_SYSTIME_LIBRARIES}
    ${KYSDK_KABASE_LIBRARIES}
    ${KYSDK_DATACOLLECT_LIBRARIES}
    ${KYSDK_UKUIWINDOWHELPER_LIBRARIES}
    ${KYSDKQTWIDGETS_LIBRARIES}
    ${KYSDKWAYLANDHELPER_LIBRARIES}
    ${CALENDAR_DEPS_LIBRARIES}
    ${GTEST_LIBRARIES}
    ${GMOCK_LIBRARIES}
    pthread
)

# Enable coverage flags
target_compile_options(test_frmlunarcalendarwidget PRIVATE --coverage)
target_link_libraries(test_frmlunarcalendarwidget PRIVATE --coverage)
