Request: Add CMAKE_<LANG>_COMPILER_LAUNCHER read from environment
sccache
has been working like a charm. Like, massive build speed improvements. However, when building VIAME, the flag -DCMAKE_<LANG>_COMPILER_LAUNCHER
did not propagate to sub-builds like fletch and ITK.
Currently solving this with a shim script which calls sccache gcc "$@"
and then export CC=/my/shim/gcc
, which does the trick, but not as clean, since it kludges the entire call to cc
.
If CMAKE_<LANG>_COMPILER_LAUNCHER
were read from the environment like other CMAKE_WHATEVER
in addition to the -D
flag, this would allow me to set the launcher across all Cmake invocations readily. @robertmaynard also expressed interest in this ability.
One particular use case would be having two base images, ubuntu:bionic
and ubuntu:bionic-sc
, the key difference being the addition of
## sccache binary
RUN wget --no-check-certificate -qO- \
https://github.com/mozilla/sccache/releases/download/0.2.8/sccache-0.2.8-x86_64-unknown-linux-musl.tar.gz | tar xvz \
&& mv sccache-0.2.8-x86_64-unknown-linux-musl/sccache /usr/local/bin/
## enable remote sccache, point to your server
ENV SCCACHE_REDIS=redis://my_redis:6379\
CMAKE_C_COMPILER_LAUNCHER=sccache\
CMAKE_CXX_COMPILER_LAUNCHER=sccache
Then, any images inheriting from -sc
tags would automagically hook into sccache. Those 5 lines could also get wrapped into a single script that could be slipped into any dockerfile before your build step.