# GoogleTest
# https://github.com/google/googletest

include(FetchContent)

FetchContent_Declare(googletest
  URL     ${CMAKE_CURRENT_LIST_DIR}/googletest-1.10.0.zip
  URL_MD5 82358affdd7ab94854c8ee73a180fc53
)

FetchContent_GetProperties(googletest)
if(NOT googletest_POPULATED)
  FetchContent_Populate(googletest)

  if (MSVC)
    # The static library version of GTest overrides CMake's /MD (dynamic CRT) with /MT (static CRT).
    # This causes linker errors when using GTest. Disable this behavior in GTest.
    set(gtest_force_shared_crt ON)
  endif()

  add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR} EXCLUDE_FROM_ALL)

  # Declare aliases to mimic imported targets
  add_library(GTest::gtest ALIAS gtest)
  add_library(GTest::gtest_main ALIAS gtest_main)
  add_library(GTest::gmock ALIAS gmock)
  add_library(GTest::gmock_main ALIAS gmock_main)
endif()
