Skip to content

Commit b36fe0f

Browse files
Make it possible to reuse built chcache binary
1 parent e1f27e5 commit b36fe0f

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,9 +620,10 @@ endif()
620620

621621
include (cmake/sanitize_targets.cmake)
622622

623-
if (COMPILER_CACHE STREQUAL "chcache")
623+
if (COMPILER_CACHE STREQUAL "chcache" AND CHCACHE_EXECUTABLE_PATH STREQUAL "")
624+
message(STATUS "Adding chcache as dependency to all other targets")
624625
get_all_targets(all_targets)
625-
set (chcache_targets _cargo-build_chcache cargo-build_chcache cargo-prebuild_chcache)
626+
set(chcache_targets _cargo-build_chcache cargo-build_chcache cargo-prebuild_chcache)
626627
foreach(target ${all_targets})
627628
if (target IN_LIST chcache_targets)
628629
continue()

cmake/ccache.cmake

Lines changed: 9 additions & 1 deletion
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)
@@ -27,7 +29,13 @@ elseif (COMPILER_CACHE STREQUAL "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 built chcache")
34+
set(CCACHE_EXECUTABLE ${CMAKE_CURRENT_BINARY_DIR}/rust/chcache/chcache)
35+
else()
36+
message(STATUS "Using 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)