Skip to content

Commit 7198a46

Browse files
committed
cmake [KILL 3-STATE]: Switch WITH_CCACHE to boolean
`WITH_CCACHE` is an opportunistic option now and its default is `ON`.
1 parent ba26fe6 commit 7198a46

File tree

5 files changed

+28
-107
lines changed

5 files changed

+28
-107
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ jobs:
133133
if: github.repository != 'bitcoin-core/gui' || github.event_name == 'pull_request'
134134

135135
env:
136-
CCACHE_MAXSIZE: '200M'
137136
PYTHONUTF8: 1
138137
TEST_RUNNER_TIMEOUT_FACTOR: 40
139138

@@ -163,10 +162,6 @@ jobs:
163162
py -3 --version
164163
Write-Host "PowerShell version $($PSVersionTable.PSVersion.ToString())"
165164
166-
- name: Install Ccache
167-
run: |
168-
choco install --yes --no-progress ccache
169-
170165
- name: Using vcpkg with MSBuild
171166
run: |
172167
Set-Location "$env:VCPKG_INSTALLATION_ROOT"
@@ -197,32 +192,12 @@ jobs:
197192
path: ~/AppData/Local/vcpkg/archives
198193
key: ${{ github.job }}-vcpkg-binary-${{ hashFiles('cmake_version', 'msbuild_version', 'toolset_version', 'vcpkg.json') }}
199194

200-
- name: Restore Ccache cache
201-
id: ccache-cache
202-
uses: actions/cache/restore@v4
203-
with:
204-
path: ~/AppData/Local/ccache
205-
key: ${{ github.job }}-ccache-
206-
207195
- name: Build
208196
working-directory: build
209197
run: |
210198
ccache --zero-stats
211199
cmake --build . -j $env:NUMBER_OF_PROCESSORS --config Release
212200
213-
- name: Ccache stats
214-
run: |
215-
ccache --version | head -n 1
216-
ccache --show-stats --verbose
217-
218-
- name: Save Ccache cache
219-
uses: actions/cache/save@v4
220-
if: github.event_name != 'pull_request' && steps.ccache-cache.outputs.cache-hit != 'true'
221-
with:
222-
path: ~/AppData/Local/ccache
223-
# https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache
224-
key: ${{ github.job }}-ccache-${{ github.run_id }}
225-
226201
- name: Run test suite
227202
working-directory: build
228203
run: |

.github/workflows/cmake.yml

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -456,10 +456,6 @@ jobs:
456456
path: ~/AppData/Local/vcpkg/archives
457457
key: ${{ matrix.conf.triplet }}-vcpkg-binary-${{ hashFiles('cmake_version', 'msbuild_version', 'toolset_version', 'vcpkg.json') }}
458458

459-
- name: Install Ccache
460-
run: |
461-
choco install --yes --no-progress ccache
462-
463459
- name: Generate build system
464460
run: |
465461
cmake -B build --preset ${{ matrix.conf.preset }} -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT\scripts\buildsystems\vcpkg.cmake" -DBUILD_BENCH=ON -DBUILD_FUZZ_BINARY=ON -DWERROR=ON
@@ -471,32 +467,12 @@ jobs:
471467
path: ~/AppData/Local/vcpkg/archives
472468
key: ${{ matrix.conf.triplet }}-vcpkg-binary-${{ hashFiles('cmake_version', 'msbuild_version', 'toolset_version', 'vcpkg.json') }}
473469

474-
- name: Restore Ccache cache
475-
id: ccache-cache
476-
uses: actions/cache/restore@v4
477-
with:
478-
path: ~/AppData/Local/ccache
479-
key: ${{ matrix.conf.triplet }}-ccache-${{ github.run_id }}
480-
restore-keys: ${{ matrix.conf.triplet }}-ccache-
481-
482470
- name: Build Release configuration
483471
working-directory: build
484472
run: |
485473
ccache --zero-stats
486474
cmake --build . -j $env:NUMBER_OF_PROCESSORS --config Release
487475
488-
- name: Ccache stats
489-
run: |
490-
ccache --version | head -n 1
491-
ccache --show-stats --verbose
492-
493-
- name: Save Ccache cache
494-
uses: actions/cache/save@v4
495-
if: github.event_name != 'pull_request' && steps.ccache-cache.outputs.cache-hit != 'true'
496-
with:
497-
path: ~/AppData/Local/ccache
498-
key: ${{ matrix.conf.triplet }}-ccache-${{ github.run_id }}
499-
500476
- name: Inspect build artifacts
501477
working-directory: build
502478
run: |

CMakeLists.txt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,7 @@ cmake_dependent_option(BUILD_WALLET_TOOL "Build bitcoin-wallet tool." ${BUILD_TE
107107
option(ENABLE_HARDENING "Attempt to harden the resulting executables." ON)
108108
option(REDUCE_EXPORTS "Attempt to reduce exported symbols in the resulting executables." OFF)
109109
option(WERROR "Treat compiler warnings as errors." OFF)
110-
111-
# TODO: These tri-state options will be removed and most features
112-
# will become opt-in by default before merging into master.
113-
include(TristateOption)
114-
tristate_option(WITH_CCACHE "Use ccache for compiling." "if ccache is found." AUTO)
110+
option(WITH_CCACHE "Attempt to use ccache for compiling." ON)
115111

116112
option(WITH_NATPMP "Enable NAT-PMP." OFF)
117113
if(WITH_NATPMP)
@@ -365,6 +361,8 @@ endif()
365361

366362
include(cmake/introspection.cmake)
367363

364+
include(cmake/ccache.cmake)
365+
368366
include(cmake/crc32c.cmake)
369367
include(cmake/leveldb.cmake)
370368
include(cmake/minisketch.cmake)
@@ -498,8 +496,6 @@ configure_file(cmake/script/CoverageFuzz.cmake CoverageFuzz.cmake COPYONLY)
498496
configure_file(cmake/script/CoverageInclude.cmake.in CoverageInclude.cmake @ONLY)
499497
configure_file(contrib/filter-lcov.py filter-lcov.py COPYONLY)
500498

501-
include(cmake/optional.cmake)
502-
503499
# Don't allow extended (non-ASCII) symbols in identifiers. This is easier for code review.
504500
try_append_cxx_flags("-fno-extended-identifiers" TARGET core_base_interface SKIP_LINK)
505501

cmake/ccache.cmake

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright (c) 2023-present The Bitcoin Core developers
2+
# Distributed under the MIT software license, see the accompanying
3+
# file COPYING or https://opensource.org/license/mit/.
4+
5+
if(NOT MSVC)
6+
find_program(CCACHE_EXECUTABLE ccache)
7+
if(CCACHE_EXECUTABLE)
8+
execute_process(
9+
COMMAND readlink -f ${CMAKE_CXX_COMPILER}
10+
OUTPUT_VARIABLE compiler_resolved_link
11+
ERROR_QUIET
12+
OUTPUT_STRIP_TRAILING_WHITESPACE
13+
)
14+
if(CCACHE_EXECUTABLE STREQUAL compiler_resolved_link)
15+
set(WITH_CCACHE "ccache masquerades as the compiler")
16+
elseif(WITH_CCACHE)
17+
list(APPEND CMAKE_C_COMPILER_LAUNCHER ${CCACHE_EXECUTABLE})
18+
list(APPEND CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_EXECUTABLE})
19+
endif()
20+
else()
21+
set(WITH_CCACHE OFF)
22+
endif()
23+
endif()
24+
25+
mark_as_advanced(CCACHE_EXECUTABLE)

cmake/optional.cmake

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)