-
Notifications
You must be signed in to change notification settings - Fork 12
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
feat: use ccache for very quick recompiles if installed on build system #47
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #47 +/- ##
=======================================
Coverage 32.11% 32.11%
=======================================
Files 290 290
Lines 27470 27470
Branches 1125 1125
=======================================
Hits 8823 8823
Misses 18647 18647 ☔ View full report in Codecov by Sentry. |
CMakeLists.txt
Outdated
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_FOUND}") | ||
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCACHE_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.
Don't use RULE_LAUNCH_COMPILE
or RULE_LAUNCH_LINK
for these. Since CMake 3.4, the right way to do this is to use the CMAKE_<LANG>_COMPILER_LAUNCHER
variables instead. And ccache
doesn't cache linker commands, so there's no need to use it as a launcher for the linker.
See updated explanation here: https://crascit.com/2016/04/09/using-ccache-with-cmake/#h-improved-functionality-from-cmake-3-4
CMakeLists.txt
Outdated
find_program(CCACHE_FOUND ccache) | ||
|
||
if(CCACHE_FOUND AND ENABLE_CCACHE) | ||
set(CMAKE_CXX_COMPILER_LAUNCHER ccache) | ||
message(STATUS "Using ccache for faster recompilation") | ||
else() | ||
message(STATUS "ccache not used for compilation") | ||
endif() |
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.
- Minimize output on the configure log at the default log level. Only log abnormal or unexpected things at STATUS or higher.
- The result of
find_program()
is the location of the program, not a boolean.
find_program(CCACHE_FOUND ccache) | |
if(CCACHE_FOUND AND ENABLE_CCACHE) | |
set(CMAKE_CXX_COMPILER_LAUNCHER ccache) | |
message(STATUS "Using ccache for faster recompilation") | |
else() | |
message(STATUS "ccache not used for compilation") | |
endif() | |
if(ENABLE_CCACHE) | |
find_program(CCACHE_EXECUTABLE ccache) | |
if(CCACHE_EXECUTABLE) | |
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_EXECUTABLE}) | |
if(CMAKE_VERSION VERSION_GREATER_EQUAL 15) | |
message(VERBOSE "Enabled using ccache") | |
endif() | |
else() | |
message(WARNING "Using ccache requested, but could not find ccache executable") | |
endif() | |
endif() |
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.
@craigscott-crascit I'm unclear about your suggestion in lines 60-62 above. Why is the VERBOSE message printed only for CMake version >= 3.15?
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 VERBOSE keyword is only supported since CMake 3.15. The first line of the top level CMakeLists.txt
in this project lists CMake 3.14 as its minimum supported version. Te if()
I added was to handle the case where the developer is using CMake 3.14, to prevent making a call to message()
that would treat VERBOSE
as part of the message instead of as the message log level.
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.
I have not been keeping up to date with the cmake changes so ill defer to others
@dksmiffs |
@karljj1 understood. When I learned about @carlocorradini no, I wouldn't argue you need EDIT: No, I don't like my own suggestion above. Defaulting to |
Implements #46.