Skip to content

Commit b7aeb3c

Browse files
Make it possible to disable building chcache
1 parent b36fe0f commit b7aeb3c

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,9 @@ if (COMPILER_CACHE STREQUAL "chcache" AND CHCACHE_EXECUTABLE_PATH STREQUAL "")
624624
message(STATUS "Adding chcache as dependency to all other targets")
625625
get_all_targets(all_targets)
626626
set(chcache_targets _cargo-build_chcache cargo-build_chcache cargo-prebuild_chcache)
627+
if(NOT TARGET cargo-build_chcache)
628+
message(FATAL_ERROR "Building chcache is disabled and CHCACHE_EXECUTABLE_PATH is not set, cannot use chcache as compiler cache.")
629+
endif()
627630
foreach(target ${all_targets})
628631
if (target IN_LIST chcache_targets)
629632
continue()

cmake/ccache.cmake

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ set(COMPILER_CACHE "auto" CACHE STRING "Speedup re-compilations using the cachin
2424

2525
if(COMPILER_CACHE STREQUAL "auto")
2626
find_program (CCACHE_EXECUTABLE NAMES sccache ccache)
27-
elseif (COMPILER_CACHE STREQUAL "ccache")
27+
elseif(COMPILER_CACHE STREQUAL "ccache")
2828
find_program (CCACHE_EXECUTABLE ccache)
2929
elseif(COMPILER_CACHE STREQUAL "sccache")
3030
find_program (CCACHE_EXECUTABLE sccache)
3131
elseif(COMPILER_CACHE STREQUAL "chcache")
32-
if (CHCACHE_EXECUTABLE_PATH STREQUAL "")
33-
message(STATUS "Using built chcache")
32+
if(CHCACHE_EXECUTABLE_PATH STREQUAL "")
33+
message(STATUS "Using self-built chcache")
3434
set(CCACHE_EXECUTABLE ${CMAKE_CURRENT_BINARY_DIR}/rust/chcache/chcache)
3535
else()
36-
message(STATUS "Using chcache from ${CHCACHE_EXECUTABLE_PATH}")
36+
message(STATUS "Using already built chcache from ${CHCACHE_EXECUTABLE_PATH}")
3737
set(CCACHE_EXECUTABLE ${CHCACHE_EXECUTABLE_PATH})
3838
endif()
3939
elseif(COMPILER_CACHE STREQUAL "disabled")

rust/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
add_subdirectory (workspace)
2-
add_subdirectory (chcache)
2+
3+
option(ENABLE_CHCACHE "Enable chcache" ${ENABLE_RUST})
4+
5+
if (ENABLE_CHCACHE)
6+
add_subdirectory (chcache)
7+
endif()

0 commit comments

Comments
 (0)