From 6e85b26367c514d08a180cdfa0e59b736998bcd5 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 27 Nov 2019 13:10:00 +0100 Subject: [PATCH] enable ccache if found on system --- CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 24a6ca965..4a1a6f8dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,6 +96,18 @@ endif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64") # Find dependencies ######################################################################## +# Enable ccache if not already enabled +find_program(CCACHE_EXECUTABLE ccache) +mark_as_advanced(CCACHE_EXECUTABLE) +if(CCACHE_EXECUTABLE) + foreach(LANG C CXX) + if(NOT DEFINED CMAKE_${LANG}_COMPILER_LAUNCHER AND NOT CMAKE_${LANG}_COMPILER MATCHES ".*/ccache$") + message(STATUS "Enabling ccache for ${LANG}") + set(CMAKE_${LANG}_COMPILER_LAUNCHER ${CCACHE_EXECUTABLE} CACHE STRING "") + endif() + endforeach() +endif() + # Threads find_package(Threads REQUIRED)