CMakeConfigureLog.yaml from Python

CMake can do a variety of configure-time checks that help avoid confusing build errors. The fundamental functions for these checks are try_compile and try_run. Higher level CMake functions like check_source_compiles, check_source_runs, check_symbol_exists, etc. wrap these functions and add logic to only run the check once. Before CMake 3.26, it was difficult to manually wade through the CMake log files for these checks. CMake 3.26 added CMakeConfigureLog.yaml that is human-readable and machine-readable. We present a simple example of reading the CMakeConfigureLog.yaml in Python.

In general for CMake try_compile() and try_run(), include directories are specified like:


To preserve the scratch directories, use option:

cmake -Bbuild --debug-trycompile

which will tell the scratch directory used for try_compile() and try_run().