Mistake in FetchContent documentation

Hello everyone,

it seams to me that there is a mistake in the documentation of FetchContent.
In Populating Content Without Adding It To The Build FetchContent_MakeAvailable is used.
However, it should be FetchContent_Populate if I am not mistaken.

Thanks

@craig.scott

The example is correct, but I can see how it might be confusing. The last dot point of the FetchContent_MakeAvailable() docs states the following:

  • If the top directory of the populated content contains a CMakeLists.txt file, call add_subdirectory() to add it to the main build. It is not an error for there to be no CMakeLists.txt file, which allows the command to be used for dependencies that make downloaded content available at a known location, but which do not need or support being added directly to the build.

So in the example you highlighted, FetchContent_MakeAvailable() is being used correctly. The implied assumption in the text of the example is that there won’t be a CMakeLists.txt file, but even if there was, it wouldn’t really matter, nor would it change the example. You could use FetchContent_Populate() directly, but then you’d also need to include the check whether the content had already been populated (the project might be absorbed into a larger project hierarchy, which would mean there could be a parent that had already brought that dependency into the build). These days, using FetchContent_Populate() directly is almost never what you want, except for very specific scenarios where you always want to download. For me, I would never expect that to be the case within a project, only something I’d expect to see in a CMake script executed in script mode.