aboutsummaryrefslogtreecommitdiff
path: root/cmake/Ccache.cmake
diff options
context:
space:
mode:
authorMike Taves <mwtoews@gmail.com>2021-11-25 11:57:02 +1300
committerMike Taves <mwtoews@gmail.com>2021-11-25 11:57:02 +1300
commitcd07dcf0c4b60860188fc7829ebd20df835c68d4 (patch)
tree3b1117bfbced5853dd678104e789d181b67112c4 /cmake/Ccache.cmake
parent4889dcfa71505939966e119baa9449be189abaaf (diff)
downloadPROJ-cd07dcf0c4b60860188fc7829ebd20df835c68d4.tar.gz
PROJ-cd07dcf0c4b60860188fc7829ebd20df835c68d4.zip
Move option to module and add more comments
Diffstat (limited to 'cmake/Ccache.cmake')
-rw-r--r--cmake/Ccache.cmake16
1 files changed, 16 insertions, 0 deletions
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 <mwtoews at gmail dot com>
+#
+# 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}")