Let us examine the changes that we applied to CMakeLists.txt, by discussing them backwards.
We executed a Python script that generates print_info.c. To run the Python script, we first had to detect Python and construct the Python script. The Python script imports the configure_file function, which we defined in configurator.py. It requires that we provide it with file locations for reading and writing, as well as a dictionary holding CMake variables and their values as key-value pairs.
This recipe has shown an alternative way of generating a configuration report that can be compiled into an executable, or even a library target, by delegating the generation of sources to an external script. The first approach that we discussed ...