# How to verify configuration of the an external CMake project?

**URL:** https://discourse.cmake.org/t/how-to-verify-configuration-of-the-an-external-cmake-project/9731
**Category:** Usage
**Tags:** tool:cmake
**Created:** [December 29, 2023, 1:31am UTC](https://discourse.cmake.org/t/how-to-verify-configuration-of-the-an-external-cmake-project/9731 "2023-12-29T01:31:34Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Kentzo](https://discourse.cmake.org/user_avatar/discourse.cmake.org/kentzo/32/4122_2.png) [@Kentzo](https://discourse.cmake.org/u/Kentzo)
#### Post date: [December 29, 2023, 1:31am UTC](https://discourse.cmake.org/t/how-to-verify-configuration-of-the-an-external-cmake-project/9731/1 "2023-12-29T01:31:34Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [December 29, 2023, 3:22pm UTC](https://discourse.cmake.org/t/how-to-verify-configuration-of-the-an-external-cmake-project/9731/2 "2023-12-29T15:22:36Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Kentzo](https://discourse.cmake.org/user_avatar/discourse.cmake.org/kentzo/32/4122_2.png) [@Kentzo](https://discourse.cmake.org/u/Kentzo)
#### Post date: [December 29, 2023, 6:27pm UTC](https://discourse.cmake.org/t/how-to-verify-configuration-of-the-an-external-cmake-project/9731/3 "2023-12-29T18:27:54Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [December 29, 2023, 7:09pm UTC](https://discourse.cmake.org/t/how-to-verify-configuration-of-the-an-external-cmake-project/9731/4 "2023-12-29T19:09:55Z")

</div>

`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)
