In this recipe, we will only focus on how to fetch the Google Test sources to build the gtest_main target. For a discussion on how this target is used to test the example sources, we refer the reader to Chapter 4, Creating and Running Tests, Recipe 3, Defining a unit test and linking against Google Test:
- We first include the FetchContent module, which will provide the functions that we will require to declare, query, and populate the dependency:
include(FetchContent)
- Then, we declare the content - its name, repository location, and the precise version to fetch:
FetchContent_Declare( googletest GIT_REPOSITORY https://github.com/google/googletest.git GIT_TAG release-1.8.0)
- We then query whether the content has already been ...