CCache.cmake 744 B

123456789101112131415161718
  1. find_program(CCACHE_BIN NAMES ccache sccache)
  2. if(CCACHE_BIN)
  3. # Official ccache recommendation is to set CMAKE_C(XX)_COMPILER_LAUNCHER
  4. if (NOT CMAKE_C_COMPILER_LAUNCHER MATCHES "ccache")
  5. list(INSERT CMAKE_C_COMPILER_LAUNCHER 0 "${CCACHE_BIN}")
  6. endif()
  7. if (NOT CMAKE_CXX_COMPILER_LAUNCHER MATCHES "ccache")
  8. list(INSERT CMAKE_CXX_COMPILER_LAUNCHER 0 "${CCACHE_BIN}")
  9. endif()
  10. # ccache uses -I when compiling without preprocessor, which makes clang complain.
  11. if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
  12. set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Qunused-arguments -fcolor-diagnostics")
  13. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments -fcolor-diagnostics")
  14. endif()
  15. endif()