I try to use ccache with VS2017 using the steps described here: https://github.com/ccache/ccache/wiki/MS-Visual-Studio
Turned out, it only works for ninja and nmake projects which is unacceptable for our working environment. Also the UseMultiToolTask
property is only available in VS2019 and above.
Rewiring the compiler is not enough. ccache needs one cpp on the input, and is able to return one obj file on the output. CL.exe is compiling the cpp files in batches(.rsp file) which results in many .obj files in the output folder.
I was able to get around this by changing one line in my Microsoft.CppCommon.targets file:
I have replaced in Sources="@(ClCompile)"
with
Sources="%(ClCompile.Identity)"
in the according CL task
and with this hack the ccache is working perfectly.
Now my question is how to override CLCompile properly. I need to have a .targets file somewhere on my computer which will contain the override and I will import it in my vcxprojs. What should I write in that .targets file?