Skip to content

Commit

Permalink
build: Improve ccache performance for different build directories
Browse files Browse the repository at this point in the history
  • Loading branch information
hebasto committed Jan 16, 2025
1 parent 051857f commit 005dd06
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions cmake/ccache.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 <LANG>_COMPILER_LAUNCHER target property, used to integrate
# Ccache, is supported only by the Makefiles and Ninja generators.
if(CMAKE_GENERATOR MATCHES "Makefiles|Ninja")
find_program(CCACHE_EXECUTABLE ccache)
if(CCACHE_EXECUTABLE)
execute_process(
Expand All @@ -17,8 +19,11 @@ 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)
set(CMAKE_${lang}_COMPILER_LAUNCHER
${CMAKE_COMMAND} -E env CCACHE_NOHASHDIR=1 ${CCACHE_EXECUTABLE}
)
endforeach()
endif()
else()
set(WITH_CCACHE OFF)
Expand Down

0 comments on commit 005dd06

Please sign in to comment.