CompileCache.cmake 754 B

1234567891011121314151617181920212223242526
  1. option(USE_COMPILE_CACHE "Use ccache or clcache for compilation" OFF)
  2. # Compatibility for old option name
  3. if(USE_CCACHE)
  4. set(USE_COMPILE_CACHE ON)
  5. endif()
  6. if(USE_COMPILE_CACHE)
  7. if(MSVC)
  8. set(CACHE_TOOL_NAME clcache)
  9. elseif(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|AppleClang|Clang)")
  10. set(CACHE_TOOL_NAME ccache)
  11. else()
  12. message(WARNING "Compile cache only available with MSVC or GNU")
  13. endif()
  14. find_program(CACHE_TOOL ${CACHE_TOOL_NAME})
  15. if (CACHE_TOOL)
  16. message(STATUS "Using ${CACHE_TOOL} found for caching")
  17. set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CACHE_TOOL})
  18. set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CACHE_TOOL})
  19. else()
  20. message(WARNING "USE_COMPILE_CACHE enabled, but no ${CACHE_TOOL_NAME} found")
  21. endif()
  22. endif()