How to verify configuration of the an external CMake project?

I’m using the ExternalProject module to set up a dependency sub-project. This sub-project does some find_package-like detection and auto-configures itself accordingly.

In the main project I want to verify that it found everything I expected it to find by checking variables it sets.

My idea was to add a custom step between the configure and build steps, but I’m not sure what is the portable way to query configuration settings of an arbitrary CMake build directory.

Do I need to grep CMakeCache.txt, grep the output of cmake -L or do something else?

I think a patch step that injects some code to dump out the variables in question in whatever form you need would be best. Another step could read that and do whatever signaling is needed.

Could you recommend any specific approach to actually read from CMakeCache.txt?

CMakeCache.txt only has access to cached values. If you have cached:BOOL=1 in the cache and a local value of set(cached 0), the value in the code is 0. I would recommend extracting values during the actual configure rather than the cache.

I’m not sure the cache format is well-documented and I know it has holes in its parsing (spurious newlines come to mind)