Module Introduction: CMake Dependencies

Free Preview
You must first complete CMake: Initial Build Setup before viewing this Lesson

Most projects rely on external source code or external libraries in some form. Most times, external dependencies are copied into the source tree or included as git submodules. This method provides the tightest coupling of external code to our project and works regardless of the underlying build system.

Thanks to modern build tools, such as CMake and Meson, as well as package managers like Conan, we now can treat external dependencies properly, instead of coupling them tightly inside our repositories. We can search for dependencies that are already installed on our system, and we can automatically download dependencies which aren’t.

In this module, we’ll integrate two external libraries that are used by our libc implementation:

We’ll also use the CMocka testing framework for our libc unit tests. We’ll implement logic that will use an installed version if it exists on our computer. If it does not, we’ll automatically download the project, compile it, and link with our test program.

Managing external dependencies on our projects is a common challenge. This module will give you the vocabulary you need to effectively manage dependencies.

Back to: Creating a Cross-Platform Build System for Embedded Projects with CMake > CMake: Dependencies