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.

Defining custom commands to generate output

Defining custom commands to generate output - C++ Tutorial

From the course: Advanced C++: Building Projects with CMake

Defining custom commands to generate output

- [Instructor] Custom commands are a powerful feature in CMake that let us extend our build process beyond just compiling code. They are essential for real world projects where you need to generate files, process resources, or run scripts as part of your build. In this video, we'll create a custom command that generates a text file containing real project and build information. We'll keep working with the top level CMakeLists.txt file. Use add_custom_command to create a, well, custom command. Next, the OUTPUT command tells CMake to generate a file called build_info.txt in the top level build folder. The first command writes the text ImageLite Build Information to the file. Note that we're using add_custom_command with CMake's built-in -E script mode commands, which are intentionally designed to be cross-platform. The second command appends the CMake version after it. We're relying on predefined CMake variables to fetch the information we want to include in this file. Here…

Contents