-
Notifications
You must be signed in to change notification settings - Fork 83
Integration
There are various approaches to integrating clcache in a build system. In principle, about any build system works with clcache but there are some things to consider.
A generic approach to integrating clcache into a build process is to
- generate an executable build
- rename
clcache.exe
tocl.exe
-
prepend the directory in which
clcache.exe
is stored to thePATH
environment variable
This way, most build systems will pick up clcache transparently by calling cl.exe
as before, and clcache will forward calls to the original compiler as needed by scanning the PATH
environment variable for another executable named cl.exe
.
Some users have reported (see e.g. #18) that in order to make Visual Studio pick up clcache
, the original compiler binary needs to be moved out of the way and replaced with an executable file:
- Rename
cl.exe
to e.g.cl_original.exe
- Rename
cl.exe.config
to e.g.cl_original.exe.config
- Copy the generated
clcache.exe
file tocl.exe
- Set
CLCACHE_CL
environment variable to point tocl_original.exe
.
The last step will tell clcache that the original compiler to forward calls to is no longer available using the default name.
This method is especially handy when there are multiple Python installations on a system (but Chocolatey is not available), or when hacking on the clcache source code:
Create a file clcache.bat
and put it in a directory mentioned in the PATH
environment variable (e.g. %HOME%\bin
):
@echo off
@setlocal
rem this is a good place for clcache environment variables
set CLCACHE_HARDLINK=1
C:\Python35\python.exe C:\clcache\clcache.py %*
Now set your compiler to clcache.bat
in the build system, e.g. for CMake
set CC=clcache.bat
set CXX=clcache.bat
cmake ..
nmake
Check stats via clcache.bat -s
, clear cache clcache.bat -C
and so on.