# When to reconfigure vs configure from scratch? Why?

**URL:** https://discourse.cmake.org/t/when-to-reconfigure-vs-configure-from-scratch-why/3670
**Category:** Usage
**Created:** [July 1, 2021, 8:34pm UTC](https://discourse.cmake.org/t/when-to-reconfigure-vs-configure-from-scratch-why/3670 "2021-07-01T20:34:19Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![thejohnfreeman](https://discourse.cmake.org/user_avatar/discourse.cmake.org/thejohnfreeman/32/1531_2.png) [@thejohnfreeman](https://discourse.cmake.org/u/thejohnfreeman)
#### Post date: [July 1, 2021, 8:34pm UTC](https://discourse.cmake.org/t/when-to-reconfigure-vs-configure-from-scratch-why/3670/1 "2021-07-01T20:34:19Z")

</div>

In my testing, I’ve noticed that there are many configuration changes that do not affect the build. Say I initially configure and build my project like this (I’m testing with 3.17):

```auto
cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake -S . -B .build
cmake --build .build

```

Then say I make changes to the toolchain file and try to reconfigure:

```auto
cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake -S . -B .build

```

Exact same command as before, but I get this error:

```auto
CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_TOOLCHAIN_FILE

```

The [documentation](https://cmake.org/cmake/help/latest/variable/CMAKE_TOOLCHAIN_FILE.html) for `CMAKE_TOOLCHAIN_FILE` does not say it is ignored after the first configuration. Why is it?

Now let’s say I reconfigure, changing a variable on the command line:

```auto
cmake -DBUILD_SHARED_LIBS=ON -S . -B .build

```

If I branch on that variable to change some options to a call to `find_library` or `find_path`, the call will return the same results as it did in the first configuration. I guess if the cache is present, then those functions just return whatever is in there.

If I have a specific configuration change in mind, how can I tell ahead of time whether reconfiguration will incorporate that change? When is reconfiguration prohibited? When is it recommended? Should I just always start a fresh configuration (throwing away intermediate build artifacts) after every configuration change?

---

<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: [July 1, 2021, 10:50pm UTC](https://discourse.cmake.org/t/when-to-reconfigure-vs-configure-from-scratch-why/3670/2 "2021-07-01T22:50:31Z")

</div>

> [@thejohnfreeman](#):
>
> how can I tell ahead of time whether reconfiguration will incorporate that change?

In general, you can’t. _Most_ projects are OK with flipping options and running off of cached results, but others are not. I’ll also note that `Find` modules usually want everything they make cleared before finding a different installation of the same package though.

> [@thejohnfreeman](#):
>
> The [documentation](https://cmake.org/cmake/help/latest/variable/CMAKE_TOOLCHAIN_FILE.html) for `CMAKE_TOOLCHAIN_FILE` does not say it is ignored after the first configuration. Why is it?

It probably should. CMake doesn’t support changing the compiler after the initial configure (where a compiler is successfully found) because it builds all kinds of knowledge up based on that discovered compiler that undoing it all is very unreliable, so it’s just best to start from scratch in that case.
