# CCache with Visual Studio Generator causing files to be compiled always

**URL:** https://discourse.cmake.org/t/ccache-with-visual-studio-generator-causing-files-to-be-compiled-always/11342
**Category:** Usage
**Tags:** os:windows, gen:vs
**Created:** [July 29, 2024, 9:37am UTC](https://discourse.cmake.org/t/ccache-with-visual-studio-generator-causing-files-to-be-compiled-always/11342 "2024-07-29T09:37:36Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![siddmohsin](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@siddmohsin](https://discourse.cmake.org/u/siddmohsin)
#### Post date: [July 29, 2024, 9:37am UTC](https://discourse.cmake.org/t/ccache-with-visual-studio-generator-causing-files-to-be-compiled-always/11342/1 "2024-07-29T09:37:36Z")

</div>

Hello All,

I picked up compiler caching subject again for C++ on windows using Visual Studio Generator. I was reading ProfessionalCMake\_18th\_Edition.pdf and this book has complete section compiler cache wehere in compile caching using ccache is being exained greatly. I must say its great book. Thanks @craig.scott for the book.

I followed book and it seems caching is working (not 100% but greatly) but one thing I noticed, even though I have compiled my library and without any change in source file, if I compile same library again it compiles the all sources of that library. This is very unusual. I tried to figure out what is happening but could not understand the same.

So every time I build it always builds all source file which seems not right behaviour.

I am attaching the sample reproducible project . Would appreciate help on any direction here.  
[WorkspaceCCache.zip](https://discourse.cmake.org/uploads/short-url/fIK5a0lAypCbUa15pfNRPmcuZka.zip) (6.3 KB)

---

<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 19, 2025, 1:55pm UTC](https://discourse.cmake.org/t/ccache-with-visual-studio-generator-causing-files-to-be-compiled-always/11342/2 "2025-07-19T13:55:11Z")

</div>

I’m not familiar with VS enough to debug it, but if it happens with the `Ninja` generator, you can use `ninja -d explain` to see why `ninja` is running a rule. `msbuild` may provide this information as well. That’s where I’d start.
