This repository was archived by the owner on Feb 4, 2020. It is now read-only.

Description
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