# Using a compiler cache on Windows with MSVC?

**URL:** https://discourse.cmake.org/t/using-a-compiler-cache-on-windows-with-msvc/13694
**Category:** Usage
**Tags:** os:windows, gen:vs
**Created:** [March 7, 2025, 2:11pm UTC](https://discourse.cmake.org/t/using-a-compiler-cache-on-windows-with-msvc/13694 "2025-03-07T14:11:36Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![exoosh](https://discourse.cmake.org/user_avatar/discourse.cmake.org/exoosh/32/4077_2.png) [@exoosh](https://discourse.cmake.org/u/exoosh)
#### Post date: [March 7, 2025, 2:11pm UTC](https://discourse.cmake.org/t/using-a-compiler-cache-on-windows-with-msvc/13694/1 "2025-03-07T14:11:36Z")

</div>

Hi,

the documentation of [`<LANG>_COMPILER_LAUNCHER`](https://cmake.org/cmake/help/latest/prop_tgt/LANG_COMPILER_LAUNCHER.html) suggests — although not in very explicit terms — that only `Unix Makefiles` and `Ninja` are supported for this property:

> Specify a [semicolon-separated list](https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#cmake-language-lists) containing a command line for a compiler launching tool. The [Makefile Generators](https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html#makefile-generators) and the [`Ninja`](https://cmake.org/cmake/help/latest/generator/Ninja.html#generator:Ninja) generator will run this tool and pass the compiler and its arguments to the tool. Some example tools are distcc and ccache.

Neither [`CMAKE_<LANG>_COMPILER_LAUNCHER` (env. var.)](https://cmake.org/cmake/help/latest/envvar/CMAKE_LANG_COMPILER_LAUNCHER.html) nor [`CMAKE_<LANG>_COMPILER_LAUNCHER`](https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_LAUNCHER.html) hint at any limitations as of the current documentation version (4.0.0-rc3).

So could someone please clarify, is this a supported scenario or not? In case it matters: this is C and C++.

Thank you.

---

<div class="post-metadata">

### Author: ![Angew](https://discourse.cmake.org/user_avatar/discourse.cmake.org/angew/32/229_2.png) [@Angew](https://discourse.cmake.org/u/Angew)
#### Post date: [March 7, 2025, 2:21pm UTC](https://discourse.cmake.org/t/using-a-compiler-cache-on-windows-with-msvc/13694/2 "2025-03-07T14:21:41Z")

</div>

It’s very indirect indeed, but it boils down to this chain:

1. Environment variable `CMAKE_<LANG>_COMPILER_LAUNCHER` pre-populates CMake cache variable `CMAKE_<LANG>_COMPILER_LAUNCHER` if no other value is specified for the latter.
2. The value of CMake cache variable `CMAKE_<LANG>_COMPILER_LAUNCHER` when a target is created is used as the initial value of the target’s property `<LANG>_COMPILER_LAUNCHER`
3. The docs of `<LANG>_COMPILER_LAUNCHER` suggest that it only applies with Makefile and Ninja generators.

So while there is no explicit limitation to Make/Ninja mentioned in the variables’ documentation, it follows from the way they work. They only affect the property, and the property only applies to Make/Ninja.

---

<div class="post-metadata">

### Author: ![exoosh](https://discourse.cmake.org/user_avatar/discourse.cmake.org/exoosh/32/4077_2.png) [@exoosh](https://discourse.cmake.org/u/exoosh)
#### Post date: [March 7, 2025, 2:24pm UTC](https://discourse.cmake.org/t/using-a-compiler-cache-on-windows-with-msvc/13694/3 "2025-03-07T14:24:07Z")

</div>

Fair enough, thanks! So it’s _not_ supported. Just wondering: when someone wants to affect the property they’ll be told to use the environment variable or CMake variable. Does it make sense to raise this as a ticket on the project?
