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.

Automating build tasks

Automating build tasks

- [Instructor] In this video, we'll explore practical ways to automate build tasks with CMake, saving us time and reducing manual steps in the build process. These techniques are especially valuable in larger projects where repetitive tasks can slow down development. Let's look at a practical example, automating code generation. For our ImageLite project, we'll generate a header file at build time that contains information about supported image formats. I've gone ahead and created a Python script called generate_formats. You can find it in the scripts directory. The script generates a C++ header with an array of supported image formats. Next, we'll update our top level CMakeLists.txt to include the generation step in the build process. We'll add these commands after we've defined our main targets, but before we set up the final dependencies, so after target_include_directories. Now first we need to make sure Python is available. I'll use find package to check if the Python interpreter…

Contents