How it works

The FetchContent module enables populating content at configure time. In our case, we have fetched a Git repository with a well defined Git tag:

FetchContent_Declare(  googletest  GIT_REPOSITORY  GIT_TAG release-1.8.0)

The FetchContent module supports fetching content via any method supported by the ExternalProject module - in other words, via Subversion, Mercurial, CVS, or HTTP(S). The content name "googletest" was our choice and with this we will be able to reference the content when querying its properties, when populating directories, and later also when configuring the subproject. Before populating the project, we checked whether the content was already fetched, otherwise FetchContent_Populate() ...

Get CMake Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.