-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Minimal CMake
By :

FetchContent
is a relatively new addition to CMake, only appearing in CMake 3.11 in March 2018. FetchContent
allows you to provide a path to a source library (this is usually a repository URL of some kind, though a URL to a ZIP file or local directory path is also supported) and have CMake download (or fetch) the code for you. In the most basic case, this path is all that you need to provide (we’ll cover some of the additional arguments shortly).
An incredibly valuable property of FetchContent
is that it allows you to keep the source of any third-party dependency out of your codebase. When working with a third-party library without using FetchContent
, there are a few different options, all with various trade-offs. One solution is to copy/paste the third-party library into your source directory (ideally in a well-designated folder). If that project is using CMake, it’s possible to use a feature called add_subdirectory
to...