Preprocessor Configuration: Header

Let's learn about how the preprocessor configures headers.

In this lesson, we'll cover how we can use CMake to configure included headers.

Configuring the headers

Passing definitions through target_compile_definitions() can be a bit of an overhead if we have multiple variables. Can't we just provide a header file with placeholders referencing various variables and get CMake to fill them in?

Sure we can! With the configure_file() command, we can generate new files from templates like this one:

Get hands-on with 1200+ tech skills courses.