2020-08-14 15:44:04 +00:00
|
|
|
option(ENABLE_CCACHE "Speedup re-compilations using ccache" ON)
|
|
|
|
|
|
|
|
if (NOT ENABLE_CCACHE)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
2017-09-09 00:32:34 +00:00
|
|
|
find_program (CCACHE_FOUND ccache)
|
2019-08-30 17:40:27 +00:00
|
|
|
|
2017-09-09 00:32:34 +00:00
|
|
|
if (CCACHE_FOUND AND NOT CMAKE_CXX_COMPILER_LAUNCHER MATCHES "ccache" AND NOT CMAKE_CXX_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")
|
|
|
|
#message(STATUS "Using ${CCACHE_FOUND} ${CCACHE_VERSION}")
|
|
|
|
set_property (GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_FOUND})
|
|
|
|
set_property (GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE_FOUND})
|
|
|
|
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-14 15:44:04 +00:00
|
|
|
elseif (NOT CCACHE_FOUND)
|
|
|
|
message (${RECONFIGURE_MESSAGE_LEVEL} "Cannot use ccache")
|
2017-09-09 00:32:34 +00:00
|
|
|
endif ()
|