|
8 | 8 | ON or OFF. |
9 | 9 | ]] |
10 | 10 |
|
| 11 | +# Find and enable ccache for compiling |
11 | 12 | find_program (CCACHE_EXECUTABLE ccache) |
12 | | - |
13 | | -# Enable ccache for compiling if not already configured. |
14 | | -if (CCACHE_EXECUTABLE AND NOT DEFINED MONGO_USE_CCACHE) |
| 13 | +if (CCACHE_EXECUTABLE) |
15 | 14 | message (STATUS "Found ccache: ${CCACHE_EXECUTABLE}") |
16 | | - |
17 | | - execute_process ( |
18 | | - COMMAND ${CCACHE_EXECUTABLE} --version | perl -ne "print $1 if /^ccache version (.+)$/" |
19 | | - OUTPUT_VARIABLE CCACHE_VERSION |
20 | | - OUTPUT_STRIP_TRAILING_WHITESPACE |
21 | | - ) |
22 | | - |
23 | | - # Assume `ccache --version` mentions a simple version string, e.g. "1.2.3". |
24 | | - # Permit patch number to be omitted, e.g. "1.2". |
25 | | - set (SIMPLE_SEMVER_REGEX "([0-9]+)\.([0-9]+)(\.([0-9]+))?") |
26 | | - string (REGEX MATCH "${SIMPLE_SEMVER_REGEX}" CCACHE_VERSION ${CCACHE_VERSION}) |
27 | | - |
28 | | - if (CCACHE_VERSION) |
29 | | - message (STATUS "Detected ccache version: ${CCACHE_VERSION}") |
30 | | - else () |
31 | | - message (WARNING "Could not obtain ccache version from `ccache --version`. Defaulting to 0.1.0.") |
32 | | - set (CCACHE_VERSION 0.1.0) |
33 | | - endif () |
34 | | - |
35 | | - # Avoid spurious "ccache.conf: No such file or directory" errors due to ccache being invoked in parallel, which was patched in ccache version 3.4.3. |
36 | | - if (CCACHE_VERSION VERSION_LESS "3.4.3") |
37 | | - message (STATUS "Detected ccache version ${CCACHE_VERSION} is less than 3.4.3, which may lead to spurious failures when run in parallel. See https://github.com/ccache/ccache/issues/260 for more information.") |
38 | | - message (STATUS "Compiling with CCache disabled. Enable by setting MONGO_USE_CCACHE to ON") |
39 | | - option (MONGO_USE_CCACHE "Use CCache when compiling" OFF) |
40 | | - else () |
41 | | - message (STATUS "Compiling with CCache enabled. Disable by setting MONGO_USE_CCACHE to OFF") |
42 | | - option (MONGO_USE_CCACHE "Use CCache when compiling" ON) |
43 | | - endif () |
44 | | -endif (CCACHE_EXECUTABLE AND NOT DEFINED MONGO_USE_CCACHE) |
| 15 | + option (MONGO_USE_CCACHE "Use CCache when compiling" ON) |
| 16 | +endif () |
45 | 17 |
|
46 | 18 | if (MONGO_USE_CCACHE) |
| 19 | + message (STATUS "Compiling with CCache enabled. Disable by setting MONGO_USE_CCACHE to OFF") |
47 | 20 | set (CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_EXECUTABLE}") |
48 | 21 | set (CMAKE_C_COMPILER_LAUNCHER "${CCACHE_EXECUTABLE}") |
49 | 22 | endif () |
0 commit comments