Tutorial: Preparing libraries for CMake FetchContent
If you’re working on an executable project in C++, as opposed to a C++ library, using a package manager to get your dependencies might be overkill:
If all you need is to get the source code of a library, include in your CMake project, and have it compiled from source with the rest of your project, CMake’s FetchContent
module can do it for you.
If you’re a library writer, there are ways you can structure your CMake project to improve the experience for end users that use FetchContent
:
hide developer targets like tests, provide a zip archive that contains only the source files relevant downstream, and use GitHub actions to create it automatically.
Let’s see how.
» read more »