2021-08-25 21:03:30 +08:00
|
|
|
|
ADD_COMPILE_OPTIONS(-fno-access-control)
|
|
|
|
|
|
2023-02-20 10:36:55 +08:00
|
|
|
|
cmake_minimum_required(VERSION 3.16)
|
2020-07-15 20:12:25 +08:00
|
|
|
|
|
|
|
|
|
set(BIN_NAME dde_dock_unit_test)
|
|
|
|
|
|
|
|
|
|
# 自动生成moc文件
|
|
|
|
|
set(CMAKE_AUTOMOC ON)
|
|
|
|
|
|
|
|
|
|
# 源文件
|
2021-08-25 21:03:30 +08:00
|
|
|
|
file(GLOB_RECURSE SRCS
|
|
|
|
|
"*.h"
|
|
|
|
|
"*.cpp"
|
|
|
|
|
"../widgets/*.h"
|
|
|
|
|
"../widgets/*.cpp")
|
|
|
|
|
|
2022-04-25 12:53:20 +08:00
|
|
|
|
list(REMOVE_ITEM SRCS "plugins/dcc-dock-settings-plugin/*.cpp")
|
|
|
|
|
|
2021-08-25 21:03:30 +08:00
|
|
|
|
# Sources files
|
|
|
|
|
file(GLOB_RECURSE PLUGIN_SRCS
|
|
|
|
|
"../plugins/bluetooth/*.h"
|
|
|
|
|
"../plugins/bluetooth/*.cpp"
|
|
|
|
|
"../plugins/bluetooth/componments/*.h"
|
|
|
|
|
"../plugins/bluetooth/componments/*.cpp"
|
2022-04-25 12:53:20 +08:00
|
|
|
|
#"../plugins/dcc-dock-plugin/*.h"
|
|
|
|
|
#"../plugins/dcc-dock-plugin/*.cpp"
|
2021-08-25 21:03:30 +08:00
|
|
|
|
"../frame/util/horizontalseperator.h"
|
|
|
|
|
"../frame/util/horizontalseperator.cpp")
|
2020-07-15 20:12:25 +08:00
|
|
|
|
|
2022-04-25 12:53:20 +08:00
|
|
|
|
|
2021-09-23 10:13:49 +08:00
|
|
|
|
# 其包含的"interface/moduleinterface.h"文件中定义了ModuleInterface_iid,任务栏插件框架的interface文件中也有定义
|
2022-04-25 12:53:20 +08:00
|
|
|
|
#list(FILTER PLUGIN_SRCS EXCLUDE REGEX "../plugins/dcc-dock-plugin/settings_module.*")
|
2021-09-23 10:13:49 +08:00
|
|
|
|
|
2020-11-19 18:11:06 +08:00
|
|
|
|
# 用于测试覆盖率的编译条件
|
2020-12-16 17:38:41 +08:00
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage -lgcov")
|
2020-11-19 18:11:06 +08:00
|
|
|
|
|
2021-05-24 17:32:05 +08:00
|
|
|
|
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fsanitize=address -O2")
|
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fsanitize=address -O2")
|
|
|
|
|
endif()
|
|
|
|
|
|
2021-03-10 10:05:23 +08:00
|
|
|
|
# 查找gmock的cmake文件
|
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/tests/cmake/modules)
|
|
|
|
|
|
2020-07-15 20:12:25 +08:00
|
|
|
|
# 查找依赖库
|
|
|
|
|
find_package(PkgConfig REQUIRED)
|
2020-12-16 17:38:41 +08:00
|
|
|
|
find_package(Qt5Widgets REQUIRED)
|
|
|
|
|
find_package(Qt5Concurrent REQUIRED)
|
|
|
|
|
find_package(Qt5X11Extras REQUIRED)
|
|
|
|
|
find_package(Qt5DBus REQUIRED)
|
|
|
|
|
find_package(DtkWidget REQUIRED)
|
|
|
|
|
find_package(Qt5Svg REQUIRED)
|
|
|
|
|
find_package(Qt5 COMPONENTS Test REQUIRED)
|
2022-04-25 12:53:20 +08:00
|
|
|
|
#find_package(DdeControlCenter REQUIRED)
|
2020-11-19 18:11:06 +08:00
|
|
|
|
find_package(GTest REQUIRED)
|
2021-03-10 10:05:23 +08:00
|
|
|
|
find_package(GMock REQUIRED)
|
2022-05-12 17:09:10 +08:00
|
|
|
|
find_package(dbusmenu-qt5 REQUIRED)
|
2020-07-15 20:12:25 +08:00
|
|
|
|
|
2020-07-16 16:15:10 +08:00
|
|
|
|
pkg_check_modules(QGSettings REQUIRED gsettings-qt)
|
2020-12-16 17:38:41 +08:00
|
|
|
|
pkg_check_modules(DFrameworkDBus REQUIRED dframeworkdbus)
|
2022-05-12 17:09:10 +08:00
|
|
|
|
pkg_check_modules(XCB_EWMH REQUIRED xcb-image xcb-composite xtst xcb-ewmh xext dbusmenu-qt5 x11 xcursor)
|
2020-07-15 20:12:25 +08:00
|
|
|
|
|
|
|
|
|
# 添加执行文件信息
|
2021-08-25 21:03:30 +08:00
|
|
|
|
add_executable(${BIN_NAME}
|
|
|
|
|
${SRCS}
|
|
|
|
|
${INTERFACES}
|
|
|
|
|
${SRC_PATH}
|
|
|
|
|
${PLUGIN_SRCS}
|
|
|
|
|
../frame/item/item.qrc
|
|
|
|
|
ut_res.qrc)
|
2020-07-15 20:12:25 +08:00
|
|
|
|
|
|
|
|
|
# 包含路径
|
2020-12-16 17:38:41 +08:00
|
|
|
|
target_include_directories(${BIN_NAME} PUBLIC
|
|
|
|
|
${DtkWidget_INCLUDE_DIRS}
|
|
|
|
|
${XCB_EWMH_INCLUDE_DIRS}
|
|
|
|
|
${DFrameworkDBus_INCLUDE_DIRS}
|
|
|
|
|
${Qt5Gui_PRIVATE_INCLUDE_DIRS}
|
|
|
|
|
${QGSettings_INCLUDE_DIRS}
|
2022-04-25 12:53:20 +08:00
|
|
|
|
#${DdeControlCenter_INCLUDE_DIR}
|
2020-12-16 17:38:41 +08:00
|
|
|
|
../interfaces
|
2021-03-05 14:41:04 +08:00
|
|
|
|
fakedbus
|
2021-08-25 21:03:30 +08:00
|
|
|
|
../plugins/bluetooth
|
|
|
|
|
../plugins/bluetooth/componments
|
2022-04-25 12:53:20 +08:00
|
|
|
|
#../plugins/dcc-dock-plugin
|
2020-12-16 17:38:41 +08:00
|
|
|
|
)
|
2020-07-15 20:12:25 +08:00
|
|
|
|
|
|
|
|
|
# 链接库
|
|
|
|
|
target_link_libraries(${BIN_NAME} PRIVATE
|
|
|
|
|
${Qt5Test_LIBRARIES}
|
2020-12-16 17:38:41 +08:00
|
|
|
|
${XCB_EWMH_LIBRARIES}
|
2020-07-15 20:12:25 +08:00
|
|
|
|
${DFrameworkDBus_LIBRARIES}
|
2020-12-16 17:38:41 +08:00
|
|
|
|
${DtkWidget_LIBRARIES}
|
2020-11-19 18:11:06 +08:00
|
|
|
|
${Qt5Widgets_LIBRARIES}
|
2020-12-16 17:38:41 +08:00
|
|
|
|
${Qt5Concurrent_LIBRARIES}
|
|
|
|
|
${Qt5X11Extras_LIBRARIES}
|
|
|
|
|
${Qt5DBus_LIBRARIES}
|
|
|
|
|
${QGSettings_LIBRARIES}
|
|
|
|
|
${Qt5Svg_LIBRARIES}
|
2022-04-25 12:53:20 +08:00
|
|
|
|
#${DdeControlCenter_LIBRARIES}
|
2020-11-19 18:11:06 +08:00
|
|
|
|
${GTEST_LIBRARIES}
|
2021-03-10 10:05:23 +08:00
|
|
|
|
${GMOCK_LIBRARIES}
|
2020-11-19 18:11:06 +08:00
|
|
|
|
-lpthread
|
|
|
|
|
-lm
|
2020-07-15 20:12:25 +08:00
|
|
|
|
)
|
2020-12-16 17:38:41 +08:00
|
|
|
|
|
|
|
|
|
add_custom_target(check)
|
|
|
|
|
|
|
|
|
|
add_custom_command(TARGET check
|
|
|
|
|
COMMAND ./${BIN_NAME}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
add_dependencies(check ${BIN_NAME})
|