From 147b8b376345315b1c44939a6573bc53b9666883 Mon Sep 17 00:00:00 2001 From: Sven Klemm Date: Fri, 31 Jul 2026 21:24:51 +0200 Subject: [PATCH] Set CCACHE_BASEDIR when using ccache Set CCACHE_BASEDIR to the source root so ccache rewrites absolute paths to be relative. This lets different checkouts/worktrees of the same commit share cache entries. --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index af1773cbd0a..5a074a6e5cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -129,7 +129,9 @@ if((NOT DEFINED CMAKE_C_COMPILER) AND (NOT DEFINED ENV{CC})) STATUS "Using ${PG_CCACHE_FOUND} as C compiler launcher based on pg_config CC" ) - set(CMAKE_C_COMPILER_LAUNCHER ${PG_CCACHE_FOUND}) + set(CMAKE_C_COMPILER_LAUNCHER + ${CMAKE_COMMAND} -E env CCACHE_BASEDIR=${CMAKE_SOURCE_DIR} + ${PG_CCACHE_FOUND}) endif() set(PG_CC ${PG_CC_LIST}) else()