From cd07dcf0c4b60860188fc7829ebd20df835c68d4 Mon Sep 17 00:00:00 2001 From: Mike Taves Date: Thu, 25 Nov 2021 11:57:02 +1300 Subject: Move option to module and add more comments --- cmake/Ccache.cmake | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'cmake/Ccache.cmake') diff --git a/cmake/Ccache.cmake b/cmake/Ccache.cmake index 7bc59429..10b4cfd0 100644 --- a/cmake/Ccache.cmake +++ b/cmake/Ccache.cmake @@ -2,11 +2,27 @@ # CMake module to support ccache (or clcache for MSVC) # # Copyright (c) 2021, Mike Taves +# +# Usage: +# Add "include(Ccache)" to CMakeLists.txt and enable +# using the option -D USE_CCACHE=ON cmake_minimum_required(VERSION 3.4) +option(USE_CCACHE + "Use ccache (or clcache for MSVC) to compile C/C++ objects" OFF) +if(NOT USE_CCACHE) + # stop here and return to including file + return() +endif() + +# Search priority: +# 1. ccache for many compilers except MSVC +# 2. clcache for MSVC + find_program(CCACHE_PROGRAM NAMES ccache clcache) + if(CCACHE_PROGRAM) message(STATUS "Configuring ccache with ${CCACHE_PROGRAM}") -- cgit v1.2.3