ccache.cmake raw
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 AND NOT WITH_CCACHE)
15 list(APPEND configure_warnings
16 "Disabling ccache was attempted using -DWITH_CCACHE=${WITH_CCACHE}, but ccache masquerades as the compiler."
17 )
18 set(WITH_CCACHE ON)
19 elseif(WITH_CCACHE)
20 list(APPEND CMAKE_C_COMPILER_LAUNCHER ${CCACHE_EXECUTABLE})
21 list(APPEND CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_EXECUTABLE})
22 endif()
23 else()
24 set(WITH_CCACHE OFF)
25 endif()
26 else()
27 set(WITH_CCACHE OFF)
28 endif()
29
30 mark_as_advanced(CCACHE_EXECUTABLE)
31