set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )

set(kaddressbookmergelibprivate_common_SRCS)
ecm_qt_declare_logging_category(kaddressbookmergelibprivate_common_SRCS HEADER kaddressbookmergelibprivate_debug.h IDENTIFIER KADDRESSBOOKMERGELIBPRIVATE_LOG CATEGORY_NAME org.kde.pim.kaddressbookmergelibprivate)

include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/../.. )
include_directories(${CMAKE_BINARY_DIR}/kaddressbook/)

# Convenience macro to add unit tests.
macro( kaddressbook_merge _source _additional _additionallib)
    set( _test ${_source}  ${_additional})
    get_filename_component( _name ${_source} NAME_WE )
    add_executable( ${_name} ${_test} )
    add_test(NAME ${_name} COMMAND ${_name} )
    ecm_mark_as_test(kaddressbookmerge-${_name})
    target_link_libraries( ${_name} kaddressbookmergelibprivate Qt5::Test  KF5::AkonadiCore KF5::Contacts ${_additionallib})
endmacro()

kaddressbook_merge(mergecontactstest.cpp "../job/mergecontacts.cpp;../kaddressbookmergelibprivate_debug.cpp" "")

if (KDEPIM_RUN_AKONADI_TEST)
    set(KDEPIMLIBS_RUN_ISOLATED_TESTS TRUE)
    set(KDEPIMLIBS_RUN_SQLITE_ISOLATED_TESTS TRUE)

    add_akonadi_isolated_test_advanced( mergecontactinfowidgettest.cpp "../widgets/mergecontactinfowidget.cpp;${kaddressbookmergelibprivate_common_SRCS}" "KF5::AkonadiContact;KF5::KaddressbookGrantlee")
    add_akonadi_isolated_test_advanced( mergecontactwidgettest.cpp "../widgets/mergecontactinfowidget.cpp;${kaddressbookmergelibprivate_common_SRCS}" "kaddressbookmergelibprivate;KF5::KaddressbookGrantlee;KF5::Contacts;KF5::AkonadiContact;KF5::WidgetsAddons")
    add_akonadi_isolated_test_advanced( searchandmergecontactduplicatecontactdialogtest.cpp "${kaddressbookmergelibprivate_common_SRCS}" "kaddressbookmergelibprivate;KF5::Contacts")
    add_akonadi_isolated_test_advanced( searchduplicateresultwidgettest.cpp "${kaddressbookmergelibprivate_common_SRCS}" "kaddressbookmergelibprivate;KF5::KaddressbookGrantlee;KF5::Contacts;KF5::WidgetsAddons;KF5::AkonadiWidgets;KF5::AkonadiContact")
    add_akonadi_isolated_test_advanced( resultduplicatetreewidgettest.cpp "${kaddressbookmergelibprivate_common_SRCS}" "kaddressbookmergelibprivate;KF5::Contacts")
    add_akonadi_isolated_test_advanced( searchpotentialduplicatecontactjobtest.cpp "${kaddressbookmergelibprivate_common_SRCS};../job/searchpotentialduplicatecontactjob.cpp" "KF5::Contacts")
    add_akonadi_isolated_test_advanced( mergecontactselectinformationwidgettest.cpp "${kaddressbookmergelibprivate_common_SRCS}" "kaddressbookmergelibprivate;KF5::Contacts")
    add_akonadi_isolated_test_advanced( mergecontactselectlistwidgettest.cpp "${kaddressbookmergelibprivate_common_SRCS}" "kaddressbookmergelibprivate;KF5::Contacts")

    add_akonadi_isolated_test_advanced( mergecontactselectinformationscrollareatest.cpp "${kaddressbookmergelibprivate_common_SRCS};../widgets/mergecontactinfowidget.cpp" "kaddressbookmergelibprivate;KF5::Contacts;KF5::AkonadiContact;KF5::KaddressbookGrantlee")

    add_akonadi_isolated_test_advanced( mergecontactselectinformationtabwidgettest.cpp "${kaddressbookmergelibprivate_common_SRCS}" "kaddressbookmergelibprivate;KF5::Contacts")

    add_akonadi_isolated_test_advanced(mergecontactsdialogtest.cpp "${kaddressbookmergelibprivate_common_SRCS};../manualmerge/mergecontactsdialog.cpp;../widgets/mergecontacterrorlabel.cpp;../widgets/mergecontactinfowidget.cpp" "kaddressbookmergelibprivate;KF5::Contacts;KF5::AkonadiContact;KF5::KaddressbookGrantlee;KF5::I18n;KF5::WidgetsAddons")
    add_akonadi_isolated_test_advanced(mergecontactwidgetlisttest.cpp "${kaddressbookmergelibprivate_common_SRCS};../manualmerge/mergecontactwidgetlist.cpp;" "kaddressbookmergelibprivate;KF5::Contacts;KF5::AkonadiContact")

endif()

set( kaddressbook_merge_mergecontactloseinformationwarning_source mergecontactloseinformationwarningtest.cpp ../widgets/mergecontactloseinformationwarning.cpp ${kaddressbookmergelibprivate_common_SRCS})
add_executable( mergecontactloseinformationwarningtest ${kaddressbook_merge_mergecontactloseinformationwarning_source})
add_test(NAME mergecontactloseinformationwarningtest COMMAND mergecontactloseinformationwarningtest)
ecm_mark_as_test(mergecontactloseinformationwarningtest)
target_link_libraries( mergecontactloseinformationwarningtest Qt5::Test  Qt5::Gui kaddressbookmergelibprivate KF5::WidgetsAddons KF5::I18n)

