-
Notifications
You must be signed in to change notification settings - Fork 83
Installation
This page discusses various approaches for integrating clcache into your build process. In general, clcache requires a Python 3.3 or newer interpreter on the system.
You can generate a self-contained clcache.exe file using PyInstaller. If you don't have it already, installing PyInstaller is usually a matter of running
pip install pyinstaller
Afterwards, you can generate an executable by running
pyinstaller clcache.py
This will put the resulting clcache.exe binary and all its dependencies into
a dist\clcache subdirectory.
You can then tell your build system to use clcache.exe as the compiler binary, or you could rename clcache.exe to cl.exe and prepend the directory to the PATH environment variable. This way, simply running 'cl' will invoke the script instead of the real compiler.
Note: The --onefile argument to PyInstaller will make it generate a single monolithic executable file which is very convenient, but also slows things down. See the Caveats wiki page for some further discussion
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 the executable generated by PyInstaller:
- Rename
cl.exeto e.g.cl_original.exe - Rename
cl.exe.configto e.g.cl_original.exe.config - Copy
clcache.exetocl.exe - Set
CLCACHE_CLenvironment variable to point tocl_original.exe.
The last step will tell clcache.py 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.
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.