2020-08-27 11:04:17 +00:00
|
|
|
if (CMAKE_CXX_COMPILER_LAUNCHER MATCHES "ccache" OR CMAKE_CXX_COMPILER_LAUNCHER MATCHES "ccache")
|
|
|
|
set(COMPILER_MATCHES_CCACHE 1)
|
|
|
|
else()
|
|
|
|
set(COMPILER_MATCHES_CCACHE 0)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if ((ENABLE_CCACHE OR NOT DEFINED ENABLE_CCACHE) AND NOT COMPILER_MATCHES_CCACHE)
|
|
|
|
find_program (CCACHE_FOUND ccache)
|
2020-09-08 07:09:40 +00:00
|
|
|
if (CCACHE_FOUND)
|
|
|
|
set(ENABLE_CCACHE_BY_DEFAULT 1)
|
|
|
|
else()
|
|
|
|
set(ENABLE_CCACHE_BY_DEFAULT 0)
|
|
|
|
endif()
|
2020-08-27 11:04:17 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (NOT CCACHE_FOUND AND NOT DEFINED ENABLE_CCACHE AND NOT COMPILER_MATCHES_CCACHE)
|
|
|
|
message(WARNING "CCache is not found. We recommend setting it up if you build ClickHouse from source often. "
|
|
|
|
"Setting it up will significantly reduce compilation time for 2nd and consequent builds")
|
|
|
|
endif()
|
|
|
|
|
2020-09-19 16:42:36 +00:00
|
|
|
# https://ccache.dev/
|
|
|
|
option(ENABLE_CCACHE "Speedup re-compilations using ccache (external tool)" ${ENABLE_CCACHE_BY_DEFAULT})
|
2020-08-14 15:44:04 +00:00
|
|
|
|
|
|
|
if (NOT ENABLE_CCACHE)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
2020-08-27 11:04:17 +00:00
|
|
|
if (CCACHE_FOUND AND NOT COMPILER_MATCHES_CCACHE)
|
2019-08-30 17:40:27 +00:00
|
|
|
execute_process(COMMAND ${CCACHE_FOUND} "-V" OUTPUT_VARIABLE CCACHE_VERSION)
|
|
|
|
string(REGEX REPLACE "ccache version ([0-9\\.]+).*" "\\1" CCACHE_VERSION ${CCACHE_VERSION})
|
2017-09-09 00:32:34 +00:00
|
|
|
|
2019-08-30 17:40:27 +00:00
|
|
|
if (CCACHE_VERSION VERSION_GREATER "3.2.0" OR NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
2020-09-08 07:09:40 +00:00
|
|
|
message(STATUS "Using ${CCACHE_FOUND} ${CCACHE_VERSION}")
|
2021-12-29 20:25:29 +00:00
|
|
|
set(LAUNCHER ${CCACHE_FOUND})
|
2020-12-23 19:07:59 +00:00
|
|
|
|
2021-02-24 18:25:01 +00:00
|
|
|
# debian (debhelpers) set SOURCE_DATE_EPOCH environment variable, that is
|
2021-01-09 23:21:10 +00:00
|
|
|
# filled from the debian/changelog or current time.
|
2020-12-23 19:07:59 +00:00
|
|
|
#
|
2021-01-10 00:46:35 +00:00
|
|
|
# - 4.0+ ccache always includes this environment variable into the hash
|
2021-01-09 23:21:10 +00:00
|
|
|
# of the manifest, which do not allow to use previous cache,
|
2021-02-18 19:38:21 +00:00
|
|
|
# - 4.2+ ccache ignores SOURCE_DATE_EPOCH for every file w/o __DATE__/__TIME__
|
2021-01-09 23:21:10 +00:00
|
|
|
#
|
2021-12-29 20:25:29 +00:00
|
|
|
# Exclude SOURCE_DATE_EPOCH env for ccache versions between [4.0, 4.2).
|
|
|
|
if (CCACHE_VERSION VERSION_GREATER_EQUAL "4.0" AND CCACHE_VERSION VERSION_LESS "4.2")
|
2020-12-23 19:07:59 +00:00
|
|
|
message(STATUS "Ignore SOURCE_DATE_EPOCH for ccache")
|
2021-12-24 20:45:47 +00:00
|
|
|
set(LAUNCHER env -u SOURCE_DATE_EPOCH ${CCACHE_FOUND})
|
2020-12-23 19:07:59 +00:00
|
|
|
endif()
|
2021-12-24 20:45:47 +00:00
|
|
|
|
|
|
|
set (CMAKE_CXX_COMPILER_LAUNCHER ${LAUNCHER} ${CMAKE_CXX_COMPILER_LAUNCHER})
|
|
|
|
set (CMAKE_C_COMPILER_LAUNCHER ${LAUNCHER} ${CMAKE_C_COMPILER_LAUNCHER})
|
2019-08-30 17:40:27 +00:00
|
|
|
else ()
|
2020-08-14 15:44:04 +00:00
|
|
|
message(${RECONFIGURE_MESSAGE_LEVEL} "Not using ${CCACHE_FOUND} ${CCACHE_VERSION} bug: https://bugzilla.samba.org/show_bug.cgi?id=8118")
|
2019-08-30 17:40:27 +00:00
|
|
|
endif ()
|
2020-08-27 11:04:17 +00:00
|
|
|
elseif (NOT CCACHE_FOUND AND NOT COMPILER_MATCHES_CCACHE)
|
2020-08-14 15:44:04 +00:00
|
|
|
message (${RECONFIGURE_MESSAGE_LEVEL} "Cannot use ccache")
|
2017-09-09 00:32:34 +00:00
|
|
|
endif ()
|