frerich / clcache

A compiler cache for MSVC, much like ccache for gcc
Other
326 stars 83 forks source link

Alternative CMake Integration #365

Open psalvaggio opened 4 years ago

psalvaggio commented 4 years ago

I have been using ccache for a long time in CMake and have integrated it the following way:

find_program(CCACHE_FOUND ccache)
  if (CCACHE_FOUND)
    set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
    set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
  endif()

Doing it this way is nice because it requires no additional user input besides having ccache installed and it being in the user's path. So, I wanted a way to do this with clcache in a similar manner. I installed through pip and changed my original snippet to the following:

# Enable the compiler cache
if (WIN32)
  find_program(CLCACHE_FOUND clcache)
  if (CLCACHE_FOUND)
    set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE
                 "${CMAKE_CURRENT_LIST_DIR}/clcache-launcher.bat")
  endif()
else()
  find_program(CCACHE_FOUND ccache)
  if (CCACHE_FOUND)
    set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
    set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
  endif()
endif()

where clcache-launcher.bat was:

@echo off
for /f "tokens=1,* delims= " %%a in ("%*") do set ALL_BUT_FIRST=%%b
clcache %ALL_BUT_FIRST%

This got me the same semantics as using ccache, but now I get a cache on Linux/Mac and Windows in the same usage pattern.

It might be useful to add this type of pattern to the wiki for integration for people that are coming over from ccache and are used to that pattern of using a compiler cache.

Best, Phil

rweickelt commented 4 years ago

Since early 2019 this ugly workaround should no longer be necessary because clcache now determines whether the first command line argument is a compiler executable. However, the last released version is 4.2.0 which does not support it which makes me believe that this project is abandoned.

frerich commented 4 years ago

@rweickelt It's unmaintained, yes - but there are a couple of forks which may be more active. A couple of weeks ago, I mentioned this in another comment:

I never actually used MSBuild myself - in fact, I stopped using clcache many years ago since I'm not working witht Visual Studio and C++ as much as I used to. However, I'd feel a bit bad about blindly merging functionality without having at least tried i myself - which is why this promising PR did not get merged yet.

I believe many users of clcache would appreciate if this project would find a new maintainier - let me know if anyone is interested!

...which, unfortunately, was followed by awkward silence. :-(

rweickelt commented 4 years ago

Yeah, I know how it is. Great that you have developed it, it seems to work well enough with MS VS 2017. Thanks to #346, integration of clcache was very easy in our project and safes a lot of time on Travis CI.

I'd recommend @psalvaggio to try out clcache from the master branch. Installation with pip is straight forward as shown in the link above.

How to find out the most active fork?

inorton commented 4 years ago

Oh! I didn't know maintenance had slowed/stopped. @rweickelt you might have better luck then with cclash, it doesn't support PDB builds though. https://github.com/inorton/cclash but I did get some very good speedups.