-
Notifications
You must be signed in to change notification settings - Fork 455
Disable ccache by default for versions older than 3.4.3 #1029
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
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
cf43dd0
Disable ccache by default for versions older than 3.4.3
eramongodb 4053110
Guard against redundant ccache detection
eramongodb abb6078
Permit patch number to be omitted
eramongodb 033afcb
Report and handle missing ccache version string
eramongodb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -8,15 +8,43 @@ | |||||||
ON or OFF. | ||||||||
]] | ||||||||
|
||||||||
# Find and enable ccache for compiling | ||||||||
find_program (CCACHE_EXECUTABLE ccache) | ||||||||
if (CCACHE_EXECUTABLE) | ||||||||
message (STATUS "Found ccache: ${CCACHE_EXECUTABLE}") | ||||||||
option (MONGO_USE_CCACHE "Use CCache when compiling" ON) | ||||||||
endif () | ||||||||
# Find and enable ccache for compiling if not already found. | ||||||||
if (NOT DEFINED MONGO_USE_CCACHE) | ||||||||
find_program (CCACHE_EXECUTABLE 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) | ||||||||
endif (NOT DEFINED MONGO_USE_CCACHE) | ||||||||
Comment on lines
+44
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
(To match the other suggestion) |
||||||||
|
||||||||
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 () |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
find_program
needs to occur in case thatUSE_CCACHE
isTRUE
beforeCCACHE_EXECUTABLE
has been set. Thefind_program()
call is already cache-aware and will be a no-op if the variable is already set to a truth-y value (i.e. has already been set or successfully found).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, my mistake. Followup in #1031.