Skip to content

Instantly share code, notes, and snippets.

@cbandera
Created November 1, 2021 09:48
Show Gist options
  • Save cbandera/e3ffea9c645b216ca456edf4c86153bb to your computer and use it in GitHub Desktop.
Save cbandera/e3ffea9c645b216ca456edf4c86153bb to your computer and use it in GitHub Desktop.
Add Googletest to CMake via FetchContent
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.11.0
)
FetchContent_GetProperties(googletest)
if(NOT googletest_POPULATED)
FetchContent_Populate(googletest)
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR})
endif()
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment