|
5 | 5 | # Optional features and packages.
|
6 | 6 |
|
7 | 7 | if(CCACHE)
|
8 |
| - find_program(CCACHE_EXECUTABLE ccache) |
9 |
| - if(CCACHE_EXECUTABLE) |
10 |
| - set(CCACHE ON) |
| 8 | + find_program(CCACHE_COMMAND ccache) |
| 9 | + if(CCACHE_COMMAND) |
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 |
| - set(CMAKE_VS_GLOBALS |
17 |
| - "CLToolExe=${MSVC_CCACHE_WRAPPER_FILENAME}" |
18 |
| - "CLToolPath=${CMAKE_BINARY_DIR}" |
19 |
| - "TrackFileAccess=false" |
20 |
| - "UseMultiToolTask=true" |
21 |
| - "DebugInformationFormat=OldStyle" |
22 |
| - ) |
| 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_COMMAND}\" \"${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() |
23 | 31 | else()
|
24 |
| - list(APPEND CMAKE_C_COMPILER_LAUNCHER ${CCACHE_EXECUTABLE}) |
25 |
| - list(APPEND CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_EXECUTABLE}) |
| 32 | + set(CCACHE ON) |
| 33 | + list(APPEND CMAKE_C_COMPILER_LAUNCHER ${CCACHE_COMMAND}) |
| 34 | + list(APPEND CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_COMMAND}) |
26 | 35 | endif()
|
27 | 36 | elseif(CCACHE STREQUAL "AUTO")
|
28 | 37 | set(CCACHE OFF)
|
29 | 38 | else()
|
30 | 39 | message(FATAL_ERROR "ccache requested, but not found.")
|
31 | 40 | endif()
|
32 |
| - mark_as_advanced(CCACHE_EXECUTABLE) |
| 41 | + mark_as_advanced(CCACHE_COMMAND) |
33 | 42 | endif()
|
34 | 43 |
|
35 | 44 | if(WITH_NATPMP)
|
|
0 commit comments