Skip to content

FetchContent: Reduce boilerplate

When using the FetchContent module, the amount of code needed to implement the population part for most typical cases a barrier to adoption. It also looks scarier than it needs to and involves a lot of boilerplate (see #18754 (closed) for a discussion of this). For many cases, the steps are the same and it will significantly improve usability to provide a function that simply takes the name of the dependencies to populate and then iterate over them with the canonical population pattern.

This MR provides such a function, named FetchContent_MakeAvailable(). I chose that name to focus on what it does without mentioning the specifics of how the content is made available. While for now this involves populating with FetchContent_Populate() and adding to the build with add_subdirectory(), I want to allow for the possibility that in the future it may support additional methods (integration with find_package() being the one most on my mind at the moment). The key point is that after that function returns, the main project should be able to rely on the targets provided by the named dependencies being available to it.

Edited by Craig Scott

Merge request reports