less than 1 minute read

CMake supports Ccache out-of-the-box via the [CMAKE__COMPILER_LAUNCHER](https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_LAUNCHER.html) property.

Example usage via commandline

cmake -B build -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache

or within CMakePreset

// file: CMakeUserPresets.json
{
  "version": 3,
  "configurePresets": [
    {
      "name": "myPreset",
      "hidden": false,
      "cacheVariables": {
        "CMAKE_C_COMPILER_LAUNCHER": "ccache",
        "CMAKE_CXX_COMPILER_LAUNCHER": "ccache"
      }
    }
  ]
}

Tags:

Categories:

Updated: