find_package(GTest CONFIG QUIET)
if (NOT GTest_FOUND)
  FetchContent_Declare(
    GTest
    GIT_REPOSITORY https://github.com/google/googletest.git
    GIT_TAG v${GTEST_VERSION}
  )
  FetchContent_MakeAvailable(GTest)
endif()

add_executable(mag_unit_tests unit_tests.cpp)
target_link_libraries(mag_unit_tests PRIVATE mag_core GTest::gtest_main)

add_executable(mag_integration_tests integration_tests.cpp)
target_link_libraries(mag_integration_tests PRIVATE mag_core GTest::gtest_main)

include(GoogleTest)
gtest_discover_tests(mag_unit_tests
  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
  DISCOVERY_MODE PRE_TEST
)
gtest_discover_tests(mag_integration_tests
  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
  DISCOVERY_MODE PRE_TEST
)
