Home

Awesome

Actions Status

Ccache.cmake

A simple, Xcode compatible Ccache integration for CMake, based on this article by Craig Scott.

About

Ccache is a compiler cache that can drastically improve build times for C and C++ projects. This script makes it easy to configure a CMake project to use Ccache by adding the configuration option USE_CCACHE which will active Ccache support when enabled. Build-specific environmental variables can be set with the CCACHE_OPTIONS configuration parameter. It is currently compatible with Makefile, Ninja and Xcode generators. Example usage:

cmake . -DUSE_CCACHE=YES -DCCACHE_OPTIONS="CCACHE_CPP2=true;CCACHE_SLOPPINESS=clang_index_store"

How to integrate

Using CPM.cmake (recommended)

Run the following from the project's root directory to add CPM to your project.

mkdir -p cmake
wget -O cmake/CPM.cmake https://raw.githubusercontent.com/TheLartians/CPM/master/cmake/CPM.cmake

Add the following lines to the project's CMakeLists.txt after calling project(...).

include(cmake/CPM.cmake)

CPMAddPackage(
  NAME Ccache.cmake
  GITHUB_REPOSITORY TheLartians/Ccache.cmake
  VERSION 1.2
)

Using git submodules (not suited for libraries)

Run the following from the project's root directory.

git submodule add https://github.com/TheLartians/Ccache.cmake 

In add the following lines to the project's CMakeLists.txt after calling project(...).

add_subdirectory(Ccache.cmake)

Dependencies

Ccache.cmake requires CMake and Ccache.