task_plan_2/tests/CMakeLists.txt

95 lines
2.5 KiB
CMake
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

cmake_minimum_required(VERSION 3.10.0)
project(test_task_plan_2)
include(FetchContent)
if (MSVC)
add_compile_options(/utf-8)
endif()
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)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../include)
include(CTest)
enable_testing()
# 源代码目录(相对于 tests/
set(SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../src/core)
# ===== 按模块构建测试可执行文件 =====
# SU-01 事件处理测试
add_executable(test_event_processor
test_event_processor.cpp
${SRC_DIR}/event.cpp
)
target_link_libraries(test_event_processor gtest gmock gtest_main)
# SU-02 任务生成测试
add_executable(test_task_generator
test_task_generator.cpp
${SRC_DIR}/task.cpp
${SRC_DIR}/event.cpp
)
target_link_libraries(test_task_generator gtest gmock gtest_main)
# SU-03 模板管理测试
add_executable(test_template_manager
test_template_manager.cpp
${SRC_DIR}/template.cpp
)
target_link_libraries(test_template_manager gtest gmock gtest_main)
# SU-04 方案管理测试
add_executable(test_plan_manager
test_plan_manager.cpp
${SRC_DIR}/plan.cpp
)
target_link_libraries(test_plan_manager gtest gmock gtest_main)
# SU-05 分发监控测试
add_executable(test_dispatch_monitor
test_dispatch_monitor.cpp
${SRC_DIR}/dispatch.cpp
${SRC_DIR}/plan.cpp
)
target_link_libraries(test_dispatch_monitor gtest gmock gtest_main)
# 消息总线测试
add_executable(test_message_bus
test_message_bus.cpp
${SRC_DIR}/message_bus.cpp
)
target_link_libraries(test_message_bus gtest gmock gtest_main)
# 集成测试(所有模块)
add_executable(test_integration
test_integration.cpp
${SRC_DIR}/event.cpp
${SRC_DIR}/task.cpp
${SRC_DIR}/template.cpp
${SRC_DIR}/plan.cpp
${SRC_DIR}/dispatch.cpp
${SRC_DIR}/message_bus.cpp
)
target_link_libraries(test_integration gtest gmock gtest_main)
include(GoogleTest)
gtest_discover_tests(test_event_processor)
gtest_discover_tests(test_task_generator)
gtest_discover_tests(test_template_manager)
gtest_discover_tests(test_plan_manager)
gtest_discover_tests(test_dispatch_monitor)
gtest_discover_tests(test_message_bus)
gtest_discover_tests(test_integration)