include(FetchContent)
fetchcontent_declare(
	googletest
	GIT_REPOSITORY https://github.com/google/googletest.git
	GIT_TAG v1.15.2)
fetchcontent_makeavailable(googletest)

include(GoogleTest)

add_executable(
	testrunner
	TestConfig.cpp
	TestRealFrameSerializer.cpp
	TestRealFrame.cpp
	TestSinkEvents.cpp
	TestChipBugs.cpp
	TestFrameInfo.cpp)

# Resource paths are resolved at runtime from Helpers.h's location, so no payload path compile definitions are needed.
target_link_libraries(testrunner PRIVATE aeveon_decoder::core GTest::gtest_main GTest::gmock_main)
gtest_discover_tests(testrunner)

find_package(OpenCV REQUIRED COMPONENTS core imgcodecs)
add_executable(static_reconstruction_test TestStaticReconstruction.cpp)
target_link_libraries(
	static_reconstruction_test
	PRIVATE aeveon_decoder::core
			opencv_core
			opencv_imgcodecs
			GTest::gtest_main
			GTest::gmock_main)
gtest_discover_tests(static_reconstruction_test)

if(TARGET aeveon_decoder_sinks)
	find_package(OpenCV REQUIRED COMPONENTS imgcodecs)
	add_executable(reconstruction_test TestReconstruction.cpp)
	target_link_libraries(
		reconstruction_test
		PRIVATE aeveon_decoder::sinks
				opencv_imgcodecs
				GTest::gtest_main
				GTest::gmock_main)
	gtest_discover_tests(reconstruction_test)

	# Grid sinks (coefficient + motion). No image I/O, so no imgcodecs needed.
	add_executable(grid_sinks_test TestGridSinks.cpp)
	target_link_libraries(grid_sinks_test PRIVATE aeveon_decoder::sinks GTest::gtest_main GTest::gmock_main)
	gtest_discover_tests(grid_sinks_test)
endif()
