aboutsummaryrefslogtreecommitdiff
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
parent4889dcfa71505939966e119baa9449be189abaaf (diff)
downloadPROJ-cd07dcf0c4b60860188fc7829ebd20df835c68d4.tar.gz
PROJ-cd07dcf0c4b60860188fc7829ebd20df835c68d4.zip
Move option to module and add more comments
-rw-r--r--CMakeLists.txt6
-rw-r--r--cmake/Ccache.cmake16
2 files changed, 17 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c1d58405..744ee4c2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -123,11 +123,7 @@ set(PROJ_BUILD_VERSION "${PROJ_API_VERSION}.${PROJ_LIBTOOL_AGE}.${PROJ_LIBTOOL_R
# Build features and variants
################################################################################
-option(USE_CCACHE "Use ccache to compile C/C++ objects" OFF)
-if(USE_CCACHE)
- include(Ccache)
-endif()
-
+include(Ccache)
include(ProjConfig)
include(ProjMac)
include(policies)
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}")