Skip to content

Commit 72ad1e0

Browse files
Merge pull request ClickHouse#78851 from ClickHouse/reuse-built-chcache
Reuse built chcache
2 parents e1feaa5 + 0b3ba79 commit 72ad1e0

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,9 +613,11 @@ endif()
613613

614614
include (cmake/sanitize_targets.cmake)
615615

616-
if (COMPILER_CACHE STREQUAL "chcache")
616+
if (COMPILER_CACHE STREQUAL "chcache" AND CHCACHE_EXECUTABLE_PATH STREQUAL "")
617+
message(STATUS "Adding chcache as dependency to all other targets")
617618
get_all_targets(all_targets)
618-
set (chcache_targets _cargo-build_chcache cargo-build_chcache cargo-prebuild_chcache)
619+
set(chcache_targets _cargo-build_chcache cargo-build_chcache cargo-prebuild_chcache)
620+
619621
foreach(target ${all_targets})
620622
if (target IN_LIST chcache_targets)
621623
continue()

cmake/ccache.cmake

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
include(cmake/utils.cmake)
44

5+
set(CHCACHE_EXECUTABLE_PATH "" CACHE STRING "Path to chcache executable to use. If the compiler cache is set to use chcache, chcache will be used from here instead of building it.")
6+
57
# Defensive programming: early return to avoid configuring any cache after we've set dummy launchers.
68
# If something includes this file by mistake after the first setup, it'd override the dummy launchers.
79
if(USING_DUMMY_LAUNCHERS)
@@ -22,12 +24,18 @@ set(COMPILER_CACHE "auto" CACHE STRING "Speedup re-compilations using the cachin
2224

2325
if(COMPILER_CACHE STREQUAL "auto")
2426
find_program (CCACHE_EXECUTABLE NAMES sccache ccache)
25-
elseif (COMPILER_CACHE STREQUAL "ccache")
27+
elseif(COMPILER_CACHE STREQUAL "ccache")
2628
find_program (CCACHE_EXECUTABLE ccache)
2729
elseif(COMPILER_CACHE STREQUAL "sccache")
2830
find_program (CCACHE_EXECUTABLE sccache)
2931
elseif(COMPILER_CACHE STREQUAL "chcache")
30-
set(CCACHE_EXECUTABLE ${CMAKE_CURRENT_BINARY_DIR}/rust/chcache/chcache)
32+
if(CHCACHE_EXECUTABLE_PATH STREQUAL "")
33+
message(STATUS "Using self-built chcache")
34+
set(CCACHE_EXECUTABLE ${CMAKE_CURRENT_BINARY_DIR}/rust/chcache/chcache)
35+
else()
36+
message(STATUS "Using already built chcache from ${CHCACHE_EXECUTABLE_PATH}")
37+
set(CCACHE_EXECUTABLE ${CHCACHE_EXECUTABLE_PATH})
38+
endif()
3139
elseif(COMPILER_CACHE STREQUAL "disabled")
3240
message(STATUS "Using *ccache: no (disabled via configuration)")
3341
return()

0 commit comments

Comments
 (0)