且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用CCache与CMake?

更新时间:2023-09-18 08:45:46

我个人在 $ PATH $中有 / usr / lib / ccache c $ c>。这个目录包含了每个可能的名称的符号链接,可以从中调用编译器(如 gcc gcc-4.3 ) ,所有都指向ccache。



我甚至没有创建符号链接。当我在Debian上安装ccache时,该目录已预填。


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

    CC="ccache gcc" CXX="ccache g++" cmake $*

but it does not seem to work (running make still does not use ccache; I checked this using CMAKE_VERBOSE_MAKEFILE on).

Update:

As per this link I tried changing my script to

     cmake -D CMAKE_CXX_COMPILER="ccache" -D CMAKE_CXX_COMPILER_ARG1="g++" -D CMAKE_C_COMPILER="ccache" -D CMAKE_C_COMPILER_ARG1="gcc" $*

but cmake bails out complaining that a test failed on using the compiler ccache (which can be expected).

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.