# CMakeLists.txt for lunarcalendaritem unit tests
cmake_minimum_required(VERSION 3.5)

# Project name
project(test_lunarcalendaritem)

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

# Find Qt5 components
find_package(Qt5 REQUIRED COMPONENTS Core Widgets Sql DBus)

find_package(KF5WindowSystem REQUIRED)

# 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)


# Find GTest
find_package(GTest REQUIRED)

# Enable C++14 support
set(CMAKE_CXX_STANDARD 14)

# Include directories
include_directories(
    ../../../lunarcalendarwidget
    ${Qt5Core_INCLUDE_DIRS}
    ${Qt5Widgets_INCLUDE_DIRS}
    ${GTEST_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
set(SOURCES
    test_lunarcalendaritem.cpp
    main.cpp
    ../../../lunarcalendarwidget/lunarcalendaritem.cpp
    ../../../lunarcalendarwidget/lunarcalendarinfo.cpp
    ../../../lunarcalendarwidget/calendarcolor.cpp
    ../../../lunarcalendarwidget/calendardatabase.cpp
    ../../../lunarcalendarwidget/lunarcalendarwidget.cpp
    ../../../lunarcalendarwidget/schedulewidget.cpp
    ../../../lunarcalendarwidget/custommessagebox.cpp
    ../../../lunarcalendarwidget/lunarcalendaryearitem.cpp
    ../../../lunarcalendarwidget/lunarcalendarmonthitem.cpp
    ../../../lunarcalendarwidget/customscrollarea.cpp
    ../../../lunarcalendarwidget/schedule_item.cpp
    ../../../lunarcalendarwidget/colorarea.cpp
)

# Create executable
add_executable(${PROJECT_NAME} ${SOURCES})

# Link libraries
target_link_libraries(${PROJECT_NAME}
    Qt5::Core
    Qt5::Widgets
    Qt5::Sql
    Qt5::DBus
    KF5::WindowSystem
    ${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
)

# Compiler flags for coverage
target_compile_options(${PROJECT_NAME} PRIVATE --coverage)
target_link_options(${PROJECT_NAME} PRIVATE --coverage -lgcov)
