Skip to content

Set up ccache in CMake and add it to the Mac build guide - #1847

Merged
Gin890 merged 2 commits into
mainfrom
build/macos-ccache-preset
Nov 7, 2026
Merged

Gin890 merged 2 commits into
mainfrom
build/macos-ccache-preset

Conversation

@Gin890

@Gin890 Gin890 commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Continues #1767 to add ccache in CMake:

This PR adds in CMake a new option -DPA_USE_CCACHE=ON to use ccache.

When turned on, it sets ccache if ccache is installed on OS and also sets up ccache and c++ flags so the cache can be shared across worktrees. This enables cross worktree fast compiliation and benefits mutli-session AI agent development.

You can still change ccache configs via new CMake option PA_CCACHE_CONFIG.
You can also turn off the C++ compiler flags change set up to enable cross-worktree cache sharing on debug builds, by setting PA_CCACHE_DEBUG_PATHS=OFF.

  • CI doesn't change: it still uses its own ccache setup.

New worktrees and branch switches on Mac rebuild everything from scratch.
The macos-ccache preset is RelWithDebInfo plus a shared 10 GB ccache with
checkout-relative paths, so worktrees reuse each other's compiles. A short
guide is linked from the Mac build instructions. Other presets and CI are
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
Address review on #1767.

- Add cmake/Ccache.cmake, included from CMakeLists.txt. With
  -DPA_USE_CCACHE=ON (default OFF) and ccache 4.8+ installed, every compile
  runs through ccache:
  - PA_CCACHE_CONFIG: ccache settings passed on every compile's command
    line. The default keeps this project's cache in a "PA-Arduino-Source"
    folder inside ccache's own cache folder, and sets base_dir to the
    checkout's root folder, so all worktrees share one cache without
    changing ccache's global config.
  - PA_CCACHE_DEBUG_PATHS (default ON): adds -fdebug-prefix-map and
    -fdebug-compilation-dir to Debug and RelWithDebInfo builds, so builds
    with debug info share the cache across worktrees too.
  - Stops with an error if a compiler launcher is also given, or if ccache
    is older than 4.8.
- Mac build guide: install ccache as a normal step, turn it on in the
  CMake command, and add "Part 7: Tuning ccache".
- Remove the macos-ccache preset and Build-Mac-CompilerCache.md: the
  preset's settings are now in cmake/Ccache.cmake, and the guide covers
  the rest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Gin890
Gin890 force-pushed the build/macos-ccache-preset branch from fb2055a to d3c8f52 Compare November 7, 2026 04:53
@Gin890
Gin890 merged commit 8355a6a into main Nov 7, 2026
8 checks passed
@Gin890
Gin890 deleted the build/macos-ccache-preset branch November 7, 2026 05:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants