Cache.cmake 808 B

1234567891011121314151617181920212223242526272829
  1. option(ENABLE_CACHE "Enable cache if available" ON)
  2. if(NOT ENABLE_CACHE)
  3. return()
  4. endif()
  5. set(CACHE_OPTION
  6. "ccache"
  7. CACHE STRING "Compiler cache to be used")
  8. set(CACHE_OPTION_VALUES "ccache" "sccache")
  9. set_property(CACHE CACHE_OPTION PROPERTY STRINGS ${CACHE_OPTION_VALUES})
  10. list(
  11. FIND
  12. CACHE_OPTION_VALUES
  13. ${CACHE_OPTION}
  14. CACHE_OPTION_INDEX)
  15. if(${CACHE_OPTION_INDEX} EQUAL -1)
  16. message(
  17. STATUS
  18. "Using custom compiler cache system: '${CACHE_OPTION}', explicitly supported entries are ${CACHE_OPTION_VALUES}")
  19. endif()
  20. find_program(CACHE_BINARY ${CACHE_OPTION})
  21. if(CACHE_BINARY)
  22. message(STATUS "${CACHE_OPTION} found and enabled")
  23. set(CMAKE_CXX_COMPILER_LAUNCHER ${CACHE_BINARY})
  24. else()
  25. message(WARNING "${CACHE_OPTION} is enabled but was not found. Not using it")
  26. endif()