Skip to content

CDRIVER-4468 revert additional ccache checks #1100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 31, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 5 additions & 32 deletions build/cmake/CCache.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,15 @@
ON or OFF.
]]

# Find and enable ccache for compiling
find_program (CCACHE_EXECUTABLE ccache)

# Enable ccache for compiling if not already configured.
if (CCACHE_EXECUTABLE AND NOT DEFINED MONGO_USE_CCACHE)
if (CCACHE_EXECUTABLE)
message (STATUS "Found ccache: ${CCACHE_EXECUTABLE}")

execute_process (
COMMAND ${CCACHE_EXECUTABLE} --version | perl -ne "print $1 if /^ccache version (.+)$/"
OUTPUT_VARIABLE CCACHE_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)

# Assume `ccache --version` mentions a simple version string, e.g. "1.2.3".
# Permit patch number to be omitted, e.g. "1.2".
set (SIMPLE_SEMVER_REGEX "([0-9]+)\.([0-9]+)(\.([0-9]+))?")
string (REGEX MATCH "${SIMPLE_SEMVER_REGEX}" CCACHE_VERSION ${CCACHE_VERSION})

if (CCACHE_VERSION)
message (STATUS "Detected ccache version: ${CCACHE_VERSION}")
else ()
message (WARNING "Could not obtain ccache version from `ccache --version`. Defaulting to 0.1.0.")
set (CCACHE_VERSION 0.1.0)
endif ()

# 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.
if (CCACHE_VERSION VERSION_LESS "3.4.3")
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.")
message (STATUS "Compiling with CCache disabled. Enable by setting MONGO_USE_CCACHE to ON")
option (MONGO_USE_CCACHE "Use CCache when compiling" OFF)
else ()
message (STATUS "Compiling with CCache enabled. Disable by setting MONGO_USE_CCACHE to OFF")
option (MONGO_USE_CCACHE "Use CCache when compiling" ON)
endif ()
endif (CCACHE_EXECUTABLE AND NOT DEFINED MONGO_USE_CCACHE)
option (MONGO_USE_CCACHE "Use CCache when compiling" ON)
endif ()

if (MONGO_USE_CCACHE)
message (STATUS "Compiling with CCache enabled. Disable by setting MONGO_USE_CCACHE to OFF")
set (CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_EXECUTABLE}")
set (CMAKE_C_COMPILER_LAUNCHER "${CCACHE_EXECUTABLE}")
endif ()