From the course: Advanced C++: Building Projects with CMake
Unlock this course with a free trial
Join today to access over 24,900 courses taught by industry experts.
Managing external libraries using FetchContent - C++ Tutorial
From the course: Advanced C++: Building Projects with CMake
Managing external libraries using FetchContent
- [Instructor] So far, we've been working with the stb_image library by including it directly from our project's external directory using the target_include_directories command. While this approach works, it requires us to copy the STB files into our project manually. Let's explore a more sophisticated approach using CMake's FetchContent module. Managing external dependencies is one of the most challenging aspects of C++ development. Unlike languages with built-in package managers, C++ traditionally requires manual management of libraries. Our current approach with the STB library has several drawbacks. We need to manually download and place the library in our project. Updating the library requires manually replacing files. Version tracking becomes our responsibility. Other developers need to follow exact setup instructions. CMake's FetchContent module solves these problems by automatically fetching external content at configured time. Since the STB library is used only by our core…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.