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

Integration

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

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.

Generic Integration

A generic approach to integrating clcache into a build process is to

  1. generate an executable build
  2. rename clcache.exe to cl.exe
  3. prepend the directory in which clcache.exe is stored to the PATH 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.

Integration 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 an executable file:

  1. Rename cl.exe to e.g. cl_original.exe
  2. Rename cl.exe.config to e.g. cl_original.exe.config
  3. Copy the generated clcache.exe file to cl.exe
  4. Set CLCACHE_CL environment variable to point to cl_original.exe.

The last step will tell clcache that the original compiler to forward calls to is no longer available using the default name.

Integration via wrapper batch file

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.

Clone this wiki locally