如何使用CCache与CMake? [英] How to Use CCache with CMake?
问题描述
我想执行以下操作:如果CCache存在于PATH中,请使用ccache g ++进行编译,否则使用g ++。我试着写了一个小的my-cmake脚本包含
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 $*
但它似乎不工作(运行make仍然不使用ccache;我使用CMAKE_VERBOSE_MAKEFILE检查了)。
but it does not seem to work (running make still does not use ccache; I checked this using CMAKE_VERBOSE_MAKEFILE on).
更新:
根据此链接我尝试将我的脚本更改为
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" $*
但是cmake bails out抱怨测试失败使用编译器ccache(可以预期)。
but cmake bails out complaining that a test failed on using the compiler ccache (which can be expected).
推荐答案
我个人在 $ PATH
中有 / usr / lib / ccache
这个目录包含了每个可能的名称的符号链接,可以从中调用编译器(如 gcc
和 gcc-4.3
) ,所有都指向ccache。
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.
我甚至没有创建符号链接。当我在Debian上安装ccache时,该目录已预填。
And I didn't even create the symlinks. That directory comes pre-filled when I install ccache on Debian.
这篇关于如何使用CCache与CMake?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!