30 lines
856 B
Plaintext
30 lines
856 B
Plaintext
# GoogleTest配置
|
|
include(FetchContent)
|
|
FetchContent_Declare(
|
|
googletest
|
|
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
|
|
)
|
|
# For Windows: Prevent overriding the parent project's compiler/linker settings
|
|
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
|
FetchContent_MakeAvailable(googletest)
|
|
|
|
# 包含目录
|
|
include_directories(${CMAKE_SOURCE_DIR}/src)
|
|
include_directories(${CMAKE_SOURCE_DIR}/include)
|
|
|
|
# 启用测试
|
|
enable_testing()
|
|
|
|
# 添加alert_manager的单元测试
|
|
add_executable(test_alert_manager test_alert_manager.cpp ../src/alert_manager.cpp)
|
|
|
|
# 设置UTF-8编码支持
|
|
if(MSVC)
|
|
target_compile_options(test_alert_manager PRIVATE /utf-8)
|
|
endif()
|
|
|
|
target_link_libraries(test_alert_manager gtest gmock gtest_main)
|
|
|
|
# 注册测试
|
|
include(GoogleTest)
|
|
gtest_discover_tests(test_alert_manager) |