# Copyright (C) 2020 Uniontech Technology Co., Ltd.
#
# Author:     xinbo wang <wangxinbo@uniontech.com>
#
# Maintainer: xinbo wang <wangxinbo@uniontech.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

set(TEST_NAME ut-displayjack)

file(GLOB_RECURSE INCLUDE_FILES "../include/qt/wmjack*.h" "../include/wmjack/dtk_wmjack.h")
file(GLOB_RECURSE SRCS
    "../qt/wmjack/*.h"
    "../qt/wmjack/*.cpp"
)

include_directories(
    "../include/wmjack/"
    "../include/qt/wmjack"
    "../qt/wmjack"
)

set(TEST_FILES
    main.cpp
    ./wmjack/ut_wmjack.cpp
    )

add_definitions(-DUSE_FAKE_INTERFACE)
add_executable(${TEST_NAME}
    ${INCLUDE_FILES}
    ${SRCS}
    ${TEST_FILES}
    ${DFAKE_INTERFACE_DBUS_XML}
)

find_package(PkgConfig REQUIRED)
find_package(Qt5Core)

target_include_directories(${TEST_NAME} PUBLIC
    Qt5::Core
)

target_link_libraries(${TEST_NAME} PRIVATE
    Qt5::Core
    -lpthread
    -lgcov
    -lgtest
    dtkwmjack
    qtdtkdisplay
)

if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
    target_compile_options(${TEST_NAME} PRIVATE -fprofile-instr-generate -ftest-coverage)
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
    target_compile_options(${TEST_NAME} PRIVATE -fprofile-arcs -ftest-coverage)
endif()

enable_testing()
add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME})