How it works

The foreach loop in CMakeLists.txt queries values for a number of keys and defines corresponding variables. The core function of this recipe is cmake_host_system_information, which queries system information of the host system on which CMake runs. This function can be invoked with multiple keys in one function call, but in this case, we have used one function call per key. We then use these variables to configure the placeholders in config.h.in and generate config.h . This configuration is done with the configure_file command. Finally, config.h is included in processor-info.cpp, and once compiled, it will print the values to the screen. We will revisit this approach in Chapter 5, Configure-time and Build-time Operations, and ...

Get CMake Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.