# Why does project() change CMAKE\_TOOLCHAIN\_FILE only on first configure?

**URL:** <https://discourse.cmake.org/t/why-does-project-change-cmake-toolchain-file-only-on-first-configure/8341>\
**Category:** Code\
**Created:** [June 15, 2023, 9:48pm UTC](https://discourse.cmake.org/t/why-does-project-change-cmake-toolchain-file-only-on-first-configure/8341 "2023-06-15T21:48:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dstotts\_DMRC](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/977dab/32.png) [@dstotts\_DMRC](https://discourse.cmake.org/u/dstotts_DMRC)\
**Post date:** [June 15, 2023, 9:48pm UTC](https://discourse.cmake.org/t/why-does-project-change-cmake-toolchain-file-only-on-first-configure/8341/1 "2023-06-15T21:48:47Z")

</div>

Consider:

```cmake
# CMakeLists.txt
cmake_minimum_required(VERSION 3.25)
message("Toolchain: ${CMAKE_TOOLCHAIN_FILE}")
project(ToolchainTest)
message("Toolchain: ${CMAKE_TOOLCHAIN_FILE}")

```

```cmake
# toolchain.cmake (empty file)

```

On first/clean configure:

```plaintext
> cmake -B build --toolchain toolchain.cmake .
Toolchain: toolchain.cmake
Toolchain: /Users/user/Desktop/ToolchainTest/toolchain.cmake

```

On subsequent configures:

```plaintext
> cmake -B build --toolchain toolchain.cmake .
Toolchain: toolchain.cmake
Toolchain: toolchain.cmake

```

Why does the toolchain have an absolute path after project() is called, but only on first configure?

The behavior is the same if I specify the toolchain using -DCMAKE\_TOOLCHAIN\_FILE.

I am running CMake 3.25.2

---

<div class="post-metadata">

**Author:** ![fenrir](https://discourse.cmake.org/user_avatar/discourse.cmake.org/fenrir/32/734_2.png) [@fenrir](https://discourse.cmake.org/u/fenrir)\
**Post date:** [June 16, 2023, 6:59am UTC](https://discourse.cmake.org/t/why-does-project-change-cmake-toolchain-file-only-on-first-configure/8341/2 "2023-06-16T06:59:44Z")

</div>

I guess it’s because on subsequent runs CMake skips the whole compiler detection (it’s already done the first time, so why waste resources), so it also does not bother to even look at this variable anymore.
