# CMakeLists.txt for schedulewidget unit tests
cmake_minimum_required(VERSION 3.5.0)
project(test_schedulewidget)

# 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 Sql DBus Test REQUIRED)

find_package(KF5WindowSystem REQUIRED)

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

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

)

# Source files for test
set(TEST_SOURCES
    test_schedulewidget.cpp
    ../../../lunarcalendarwidget/schedulewidget.cpp
    main.cpp
    ../../../lunarcalendarwidget/calendardatabase.cpp
    ../../../lunarcalendarwidget/custommessagebox.cpp
)

# Header files for test
set(TEST_HEADERS
    test_schedulewidget.h
)

# Source files from the project
set(PROJECT_SOURCES
    ${CMAKE_SOURCE_DIR}/../../lunarcalendarwidget/schedulewidget.cpp
)

# Header files from the project
set(PROJECT_HEADERS
    ${CMAKE_SOURCE_DIR}/../../lunarcalendarwidget/schedulewidget.h
)

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

# Link libraries
target_link_libraries(test_schedulewidget PRIVATE
    Qt5::Core
    Qt5::Widgets
    Qt5::Test
    KF5::WindowSystem
    Qt5::Sql
    Qt5::DBus
    ${Gsetting_LIBRARIES}
    ${KYSDK_DATACOLLECT_LIBRARIES}
    ${KYSDKQTWIDGETS_LIBRARIES}
    ${KYSDK_UKUIWINDOWHELPER_LIBRARIES}
    ${KYSDK_SYSTIME_LIBRARIES}
    ${KYSDK_KABASE_LIBRARIES}
)

# Enable coverage flags
target_compile_options(test_schedulewidget PRIVATE --coverage)
target_link_libraries(test_schedulewidget PRIVATE -lgcov --coverage)
