From aeb3977db51792d8ad22b0a5ff8fc5ff20d69a00 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Thu, 30 Jan 2025 15:20:52 +0000 Subject: [PATCH] build: Enhance Ccache performance across worktrees and build trees To maximize performance, it is essential to follow the recommendations in the Productivity Notes: set the `base_dir` Ccache configuration option or use the `CCACHE_BASEDIR` environment variable. --- cmake/ccache.cmake | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cmake/ccache.cmake b/cmake/ccache.cmake index d1cc204c8e..04506a990c 100644 --- a/cmake/ccache.cmake +++ b/cmake/ccache.cmake @@ -2,7 +2,9 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or https://opensource.org/license/mit/. -if(NOT MSVC) +# The _COMPILER_LAUNCHER target property, used to integrate +# Ccache, is supported only by the Makefiles and Ninja generators. +if(CMAKE_GENERATOR MATCHES "Make|Ninja") find_program(CCACHE_EXECUTABLE ccache) if(CCACHE_EXECUTABLE) execute_process( @@ -17,8 +19,9 @@ if(NOT MSVC) ) set(WITH_CCACHE ON) elseif(WITH_CCACHE) - list(APPEND CMAKE_C_COMPILER_LAUNCHER ${CCACHE_EXECUTABLE}) - list(APPEND CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_EXECUTABLE}) + foreach(lang IN ITEMS C CXX OBJCXX) + list(APPEND CMAKE_${lang}_COMPILER_LAUNCHER ${CMAKE_COMMAND} -E env CCACHE_NOHASHDIR=1 ${CCACHE_EXECUTABLE}) + endforeach() endif() else() set(WITH_CCACHE OFF)