Using FetchContent Modules
Let's learn about how to import and use FetchContent.
We'll cover the following...
Nowadays, it is recommended to go with the FetchContent module to import external projects. This module has been available in CMake since version 3.11, but we recommend using at least 3.14 to work with it effectively. 
The FetchContent module
Essentially, it's a high-level wrapper around ExternalProject, offering similar functionality and more. The key difference is in the stage of execution—unlike ExternalProject, FetchContent populates dependencies during the configuration stage, bringing all the targets declared by an external project to the scope of the main project. This way, we can use them exactly like the ones we defined ourselves. 
The usage of FetchContent module requires three steps: 
- Include the module in our project with - include(FetchModule).
- Configure dependencies with the - FetchContent_Declare()command.
- Populate dependencies with the - FetchContent_MakeAvailable()command—download, build, install, and add its list files to the main project and parse. ...