Using a compiler cache

Introduction

A compiler cache speeds up compilation times by caching object files and reusing them on subsequent builds. This even works for complete rebuilds (i.e. deleting the full build-directory). A compiler cache is automatically used when it is found by CMake.

For Linux and macOS you can use ccache. You may want to change the cache directory (environment variable CCACHE_DIR) or increase the cache size (CCACHE_MAXSIZE). See the ccache docs for configuration instructions.

You can check cache hits with ccache -s.

Usage on eve

Just load the module:

module load /global/apps/modulefiles/ccache/3.3.3

See Linux-tab!

On Windows you can use clcache. Install it with Chocolatey:

curl -L https://github.com/frerich/clcache/releases/download/v4.2.0/clcache.4.2.0.nupkg --output clcache.4.2.0.nupkg
choco install clcache --source=.

You may want to increase the cache size (to 10 GB in this case):

clcache -M 10000000000

You can check cache hits with clcache -s.

To disable caching:

cmake . -DOGS_DISABLE_COMPILER_CACHE=ON

This article was written by Lars Bilke. If you are missing something or you find an error please let us know. Generated with Hugo 0.79.0. Last revision: April 29, 2021
Commit: [cmake] Renamed OGS_DISABLE_CLCACHE to OGS_DISABLE_COMPILER_CACHE. e7b1b4255  | Edit this page on