Skip to content
This repository was archived by the owner on Feb 4, 2020. It is now read-only.

Installation

Frerich Raabe edited this page May 4, 2017 · 15 revisions

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.

Installation by modifying the executable search path

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

Installation for Visual Studio

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:

  1. Rename cl.exe to e.g. cl_original.exe
  2. Rename cl.exe.config to e.g. cl_original.exe.config
  3. Copy clcache.exe to cl.exe
  4. Set CLCACHE_CL environment variable to point to cl_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.

Installation via wrapper batch file

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.

Clone this wiki locally