|
7 | 7 | if(CCACHE)
|
8 | 8 | find_program(CCACHE_EXECUTABLE ccache)
|
9 | 9 | if(CCACHE_EXECUTABLE)
|
10 |
| - set(CCACHE ON) |
11 | 10 | if(MSVC)
|
12 |
| - # See https://github.com/ccache/ccache/wiki/MS-Visual-Studio |
13 |
| - set(MSVC_CCACHE_WRAPPER_CONTENT "\"${CCACHE_EXECUTABLE}\" \"${CMAKE_CXX_COMPILER}\"") |
14 |
| - set(MSVC_CCACHE_WRAPPER_FILENAME wrapped-cl.bat) |
15 |
| - file(WRITE ${CMAKE_BINARY_DIR}/${MSVC_CCACHE_WRAPPER_FILENAME} "${MSVC_CCACHE_WRAPPER_CONTENT} %*") |
16 |
| - list(APPEND CMAKE_VS_GLOBALS |
17 |
| - "CLToolExe=${MSVC_CCACHE_WRAPPER_FILENAME}" |
18 |
| - "CLToolPath=${CMAKE_BINARY_DIR}" |
19 |
| - "DebugInformationFormat=OldStyle" |
20 |
| - ) |
| 11 | + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24) |
| 12 | + # ccache >= 4.8 requires compile batching turned off that is available since CMake 3.24. |
| 13 | + # See https://github.com/ccache/ccache/wiki/MS-Visual-Studio |
| 14 | + set(CCACHE ON) |
| 15 | + set(MSVC_CCACHE_WRAPPER_CONTENT "\"${CCACHE_EXECUTABLE}\" \"${CMAKE_CXX_COMPILER}\"") |
| 16 | + set(MSVC_CCACHE_WRAPPER_FILENAME wrapped-cl.bat) |
| 17 | + file(WRITE ${CMAKE_BINARY_DIR}/${MSVC_CCACHE_WRAPPER_FILENAME} "${MSVC_CCACHE_WRAPPER_CONTENT} %*") |
| 18 | + list(APPEND CMAKE_VS_GLOBALS |
| 19 | + "CLToolExe=${MSVC_CCACHE_WRAPPER_FILENAME}" |
| 20 | + "CLToolPath=${CMAKE_BINARY_DIR}" |
| 21 | + "DebugInformationFormat=OldStyle" |
| 22 | + ) |
| 23 | + set(CMAKE_VS_NO_COMPILE_BATCHING ON) |
| 24 | + elseif(CCACHE STREQUAL "AUTO") |
| 25 | + message(WARNING "ccache requested and found, but CMake >= 3.24 is required to use it properly. Disabling.\n" |
| 26 | + "To skip ccache check, use \"-DCCACHE=OFF\".\n") |
| 27 | + set(CCACHE OFF) |
| 28 | + else() |
| 29 | + message(FATAL_ERROR "ccache requested and found, but CMake >= 3.24 is required to use it properly.") |
| 30 | + endif() |
21 | 31 | else()
|
| 32 | + set(CCACHE ON) |
22 | 33 | list(APPEND CMAKE_C_COMPILER_LAUNCHER ${CCACHE_EXECUTABLE})
|
23 | 34 | list(APPEND CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_EXECUTABLE})
|
24 | 35 | endif()
|
|
0 commit comments