From 1b78de3cd34c742bd5fe8633b25a114fe649f086 Mon Sep 17 00:00:00 2001 From: Andrei-Fabian-Pop Date: Thu, 21 Nov 2024 11:50:53 +0200 Subject: [PATCH] CMakeLists: Add optional fast compile using ccache Signed-off-by: Andrei-Fabian-Pop --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c95c842114..d8e6a51af5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,14 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Default build type: RelWithDebInfo" FORCE) endif() +find_program(CCACHE_FOUND ccache) +if(NOT DEFINED ENV{BUILD_HOST} AND CCACHE_FOUND) + message(STATUS "Using ccache.") + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) +else() + message(STATUS "Not using ccache.") +endif() + # Make sure our local CMake Modules path comes first list(INSERT CMAKE_MODULE_PATH 0 ${PROJECT_SOURCE_DIR}/cmake/Modules)