# Why does source file try\_compile not propagate CMAKE\_TOOLCHAIN\_FILE to the generated project?

**URL:** <https://discourse.cmake.org/t/why-does-source-file-try-compile-not-propagate-cmake-toolchain-file-to-the-generated-project/275>\
**Category:** Code\
**Created:** [November 27, 2019, 4:46pm UTC](https://discourse.cmake.org/t/why-does-source-file-try-compile-not-propagate-cmake-toolchain-file-to-the-generated-project/275 "2019-11-27T16:46:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alcroito](https://discourse.cmake.org/user_avatar/discourse.cmake.org/alcroito/32/186_2.png) [@alcroito](https://discourse.cmake.org/u/alcroito)\
**Post date:** [November 27, 2019, 4:46pm UTC](https://discourse.cmake.org/t/why-does-source-file-try-compile-not-propagate-cmake-toolchain-file-to-the-generated-project/275/1 "2019-11-27T16:46:38Z")

</div>

Looking at the generated CMakeCache.txt of a try\_compile project (via --debug-trycompile), I do not see a CMAKE\_TOOLCHAIN\_FILE cache entry, even if one was passed to the project.

In my particular case I pass the Google provided Android toolchain.

I am aware that it’s possible to set CMAKE\_TRY\_COMPILE\_PLATFORM\_VARIABLES, but shouldn’t the toolchain always propagated to source try\_compile projects?

Otherwise wouldn’t the Android toolchain logic not be executed for the try\_compile project?

---

<div class="post-metadata">

**Author:** ![fdk17](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/f/ea666f/32.png) [@fdk17](https://discourse.cmake.org/u/fdk17)\
**Post date:** [December 15, 2019, 1:04am UTC](https://discourse.cmake.org/t/why-does-source-file-try-compile-not-propagate-cmake-toolchain-file-to-the-generated-project/275/2 "2019-12-15T01:04:56Z")

</div>

The `CMAKE_TOOLCHAIN_FILE` isn’t forwarded as a cache variable for `try_compile`.  
It is included in the `CMakeSystem.cmake` file that describes the build system.

If you put a `message( "CMAKE_TOOL_CHAIN in use")` command in the toolchain file you’ll see its output during a `try_compile`.
