include(FetchContent) # Fetch Google Test FetchContent_Declare( googletest GIT_REPOSITORY https://github.com/google/googletest.git GIT_TAG v1.14.0 ) # Prevent overriding the parent project's compiler/linker settings on Windows set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) FetchContent_MakeAvailable(googletest) # Legacy simple tests (keep for backward compatibility) add_executable(rk3588_tests_legacy test_main.cpp ${CMAKE_SOURCE_DIR}/src/utils/config_expand.cpp ) target_include_directories(rk3588_tests_legacy PRIVATE ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/third_party ) target_link_libraries(rk3588_tests_legacy PRIVATE project_options Threads::Threads) add_test(NAME rk3588_tests_legacy COMMAND rk3588_tests_legacy) set_tests_properties(rk3588_tests_legacy PROPERTIES WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) if(WIN32) set_tests_properties(rk3588_tests_legacy PROPERTIES DISABLED TRUE) endif() # New Google Test based tests add_executable(rk3588_gtests test_color_analyzer.cpp test_result.cpp test_spsc_queue.cpp test_simple_json.cpp test_config_expand.cpp test_hw_factory.cpp test_frame_buffer.cpp test_behavior_event_model.cpp test_person_shoe_shape.cpp test_person_shoe_filter.cpp test_person_shoe_roi.cpp test_region_event.cpp test_action_recog.cpp test_event_fusion.cpp test_alarm_behavior_events.cpp test_log_action.cpp test_face_recog_debug.cpp test_face_gallery_search.cpp test_face_track_association.cpp test_face_track_alarm.cpp test_external_api_action.cpp test_infer_backend.cpp test_image_processor.cpp test_codec_backend.cpp ${CMAKE_SOURCE_DIR}/src/hw_factory.cpp ${CMAKE_SOURCE_DIR}/src/hw_codec.cpp ${CMAKE_SOURCE_DIR}/src/hw_image_processor.cpp ${CMAKE_SOURCE_DIR}/src/ai_scheduler.cpp ${CMAKE_SOURCE_DIR}/src/utils/config_expand.cpp ${CMAKE_SOURCE_DIR}/src/utils/dma_alloc.cpp ${CMAKE_SOURCE_DIR}/plugins/region_event/region_event_node.cpp ${CMAKE_SOURCE_DIR}/plugins/action_recog/action_recog_node.cpp ${CMAKE_SOURCE_DIR}/plugins/event_fusion/event_fusion_node.cpp ${CMAKE_SOURCE_DIR}/plugins/logic_gate/color_analyzer.cpp ${CMAKE_SOURCE_DIR}/plugins/alarm/actions/log_action.cpp ${CMAKE_SOURCE_DIR}/plugins/alarm/actions/http_action.cpp ${CMAKE_SOURCE_DIR}/plugins/alarm/actions/external_api_action.cpp ${CMAKE_SOURCE_DIR}/plugins/alarm/actions/snapshot_action.cpp ${CMAKE_SOURCE_DIR}/plugins/alarm/actions/clip_action.cpp ${CMAKE_SOURCE_DIR}/plugins/alarm/uploaders/uploader_factory.cpp ${CMAKE_SOURCE_DIR}/plugins/alarm/uploaders/local_uploader.cpp ${CMAKE_SOURCE_DIR}/plugins/alarm/uploaders/minio_uploader.cpp ${CMAKE_SOURCE_DIR}/plugins/alarm/packet_ring_buffer.cpp ${CMAKE_SOURCE_DIR}/plugins/alarm/rule_engine.cpp ) target_include_directories(rk3588_gtests PRIVATE ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/third_party ) target_compile_definitions(rk3588_gtests PRIVATE RK3588_TEST_BUILD) target_link_libraries(rk3588_gtests PRIVATE project_options rk_shared_state Threads::Threads GTest::gtest_main ) if(WIN32) add_custom_command(TARGET rk3588_gtests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ COMMENT "Copy rk_shared_state.dll next to rk3588_gtests for Windows test discovery" ) endif() include(GoogleTest) gtest_discover_tests(rk3588_gtests)