I would like to do the following: If CCache is present in PATH, use \"ccache g++\" for compilation, else use g++. I tried writing a small my-cmake script containing
I personally have /usr/lib/ccache
in my $PATH
. This directory contains loads of symlinks for every possible name the compiler could be called from (like gcc
and gcc-4.3
), all pointing to ccache.
And I didn't even create the symlinks. That directory comes pre-filled when I install ccache on Debian.
I didn't like to set a symlink from g++
to ccache
. And CXX="ccache g++"
didn't work for me as some cmake test case wanted to have just the compiler program without attributes.
So I used a small bash script instead:
#!/bin/bash
ccache g++ "$@"
and saved it as an executable in /usr/bin/ccache-g++
.
Then C configured cmake to use /usr/bin/ccache-g++
as C++ compiler.
This way it passes the cmake test cases and I feel more comfortable than having symlinks that I might forget about in 2 or 3 weeks and then maybe wonder if something doesn't work...