建议直接修改linux.toolchain.cmake 中的配置
find_program(CCACHE_PROGRAM ccache) if(CCACHE_PROGRAM) message(STATUS "Set up ccache ...") set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}") endif()
https://crascit.com/2016/04/09/using-ccache-with-cmake/
https://github.com/xizhibei/blog/issues/145
https://www.cnblogs.com/sinferwu/p/15353427.html
linux.toolchain.cmake
cmake_minimum_required( VERSION 2.6.3 ) set(CMAKE_SYSTEM_NAME Linux ) set(CMAKE_BUILD_TYPE DEBUG) SET (CMAKE_C_COMPILER "/usr/bin/clang") SET (CMAKE_C_FLAGS "-Wall -std=c99") SET (CMAKE_C_FLAGS_DEBUG "-O0 -g") SET (CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG") SET (CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG") SET (CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g") SET (CMAKE_CXX_COMPILER "/usr/bin/clang++") SET (CMAKE_CXX_FLAGS "-Wall") SET (CMAKE_CXX_FLAGS_DEBUG "-O0 -g") SET (CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG") SET (CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g") SET (CMAKE_AR "/usr/bin/llvm-ar-10") SET (CMAKE_LINKER "/usr/bin/llvm-ld-10") SET (CMAKE_NM "/usr/bin/llvm-nm-10") SET (CMAKE_OBJDUMP "/usr/bin/llvm-objdump-10") SET (CMAKE_RANLIB "/usr/bin/llvm-ranlib-10")