From e7b1b425553aafb8219e02a0360e7a6f999a4b45 Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Thu, 29 Apr 2021 14:01:07 +0200
Subject: [PATCH] [cmake] Renamed OGS_DISABLE_CLCACHE to
 OGS_DISABLE_COMPILER_CACHE.

[web] Added unified docs for ccache and clcache.
---
 CMakeLists.txt                                |  6 +-
 scripts/cmake/CLCacheSetup.cmake              |  2 +-
 scripts/cmake/Dependencies.cmake              |  2 +-
 .../docs/devguide/advanced/compiler-cache.md  | 63 +++++++++++++++++++
 .../docs/devguide/advanced/singularity.md     |  2 +-
 .../docs/devguide/advanced/using-ccache.md    | 35 -----------
 6 files changed, 67 insertions(+), 43 deletions(-)
 create mode 100644 web/content/docs/devguide/advanced/compiler-cache.md
 delete mode 100644 web/content/docs/devguide/advanced/using-ccache.md

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d771df452d4..227945e2e97 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -33,11 +33,7 @@ option(OGS_USE_CONAN "Should Conan package manager be used?" ON)
 set(OGS_CONAN_BUILD "missing" CACHE STRING "Possible values: all, missing, \
     never or list of libs to build"
 )
-if(WIN32)
-    option(OGS_DISABLE_CLCACHE "Disables clcache compiler cache." OFF)
-else()
-    option(OGS_DISABLE_CCACHE "Disables ccache compiler cache." OFF)
-endif()
+option(OGS_DISABLE_COMPILER_CACHE "Disables compiler cache." OFF)
 if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.16)
     option(OGS_USE_UNITY_BUILDS "Enables Unity builds for faster compilation."
            ON
diff --git a/scripts/cmake/CLCacheSetup.cmake b/scripts/cmake/CLCacheSetup.cmake
index 896f654800b..ecf2bed9ee4 100644
--- a/scripts/cmake/CLCacheSetup.cmake
+++ b/scripts/cmake/CLCacheSetup.cmake
@@ -1,4 +1,4 @@
-if(NOT WIN32 OR NOT CLCACHE_TOOL_PATH OR OGS_DISABLE_CLCACHE)
+if(NOT WIN32 OR NOT CLCACHE_TOOL_PATH OR OGS_DISABLE_COMPILER_CACHE)
     return()
 endif()
 
diff --git a/scripts/cmake/Dependencies.cmake b/scripts/cmake/Dependencies.cmake
index 0439c7bb351..4048b63dfa4 100644
--- a/scripts/cmake/Dependencies.cmake
+++ b/scripts/cmake/Dependencies.cmake
@@ -425,7 +425,7 @@ cpm_licenses_create_disclaimer_target(
 )
 
 # ccache
-if(NOT WIN32 AND CCACHE_TOOL_PATH AND NOT OGS_DISABLE_CCACHE)
+if(NOT WIN32 AND CCACHE_TOOL_PATH AND NOT OGS_DISABLE_COMPILER_CACHE)
     set(CCACHE_OPTIONS "CCACHE_SLOPPINESS=pch_defines,time_macros")
     if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang|AppleClang")
         list(APPEND CCACHE_OPTIONS "CCACHE_CPP2=true")
diff --git a/web/content/docs/devguide/advanced/compiler-cache.md b/web/content/docs/devguide/advanced/compiler-cache.md
new file mode 100644
index 00000000000..ada9401f199
--- /dev/null
+++ b/web/content/docs/devguide/advanced/compiler-cache.md
@@ -0,0 +1,63 @@
++++
+date = "2018-02-26T11:00:13+01:00"
+title = "Using a compiler cache"
+author = "Lars Bilke"
+weight = 1038
+
+aliases = ["/docs/devguide/advanced/using-ccache"]
+
+[menu]
+  [menu.devguide]
+    parent = "advanced"
++++
+
+## Introduction
+
+A compiler cache speeds up compilation times by caching object files and reusing them on subsequent builds. This even works for complete rebuilds (i.e. deleting the full build-directory). A compiler cache is automatically used when it is found by CMake.
+
+<div class='linux'>
+
+For Linux and macOS you can use [ccache](https://ccache.samba.org). You may want to change the cache directory (environment variable `CCACHE_DIR`) or increase the cache size (`CCACHE_MAXSIZE`). See the [ccache docs](https://ccache.dev/manual/4.2.html#_configuration) for configuration instructions.
+
+You can check cache hits with `ccache -s`.
+
+## Usage on eve
+
+Just load the module:
+
+```bash
+module load /global/apps/modulefiles/ccache/3.3.3
+```
+
+</div>
+
+<div class='mac'>
+
+See Linux-tab!
+
+</div>
+
+<div class='win'>
+
+On Windows you can use [clcache](https://github.com/frerich/clcache). Install it with [Chocolatey](https://github.com/frerich/clcache/wiki/Installation#installing-an-executable-file-via-chocolatey):
+
+```bash
+curl -L https://github.com/frerich/clcache/releases/download/v4.2.0/clcache.4.2.0.nupkg --output clcache.4.2.0.nupkg
+choco install clcache --source=.
+```
+
+You may want to increase the cache size (to 10 GB in this case):
+
+```bash
+clcache -M 10000000000
+```
+
+You can check cache hits with `clcache -s`.
+
+</div>
+
+To disable caching:
+
+```bash
+cmake . -DOGS_DISABLE_COMPILER_CACHE=ON
+```
diff --git a/web/content/docs/devguide/advanced/singularity.md b/web/content/docs/devguide/advanced/singularity.md
index 961d039804e..4c522238583 100644
--- a/web/content/docs/devguide/advanced/singularity.md
+++ b/web/content/docs/devguide/advanced/singularity.md
@@ -55,7 +55,7 @@ singularity pull docker://registry.opengeosys.org/ogs/ogs/gcc # Downloads the im
 singularity shell gcc_latest.sif
 [Now inside the container]
 mkdir build; cd build
-cmake ../ogs -DCMAKE_BUILD_TYPE=Release -DOGS_DISABLE_CCACHE=ON # OR set env var CCACHE_DIR
+cmake ../ogs -DCMAKE_BUILD_TYPE=Release -DOGS_DISABLE_COMPILER_CACHE=ON # OR set env var CCACHE_DIR
 ninja
 ./bin/ogs
 ```
diff --git a/web/content/docs/devguide/advanced/using-ccache.md b/web/content/docs/devguide/advanced/using-ccache.md
deleted file mode 100644
index 79a17b8ea73..00000000000
--- a/web/content/docs/devguide/advanced/using-ccache.md
+++ /dev/null
@@ -1,35 +0,0 @@
-+++
-date = "2018-02-26T11:00:13+01:00"
-title = "Using ccache"
-author = "Lars Bilke"
-weight = 1038
-
-[menu]
-  [menu.devguide]
-    parent = "advanced"
-+++
-
-<div class='note'>
-
-### <i class="far fa-exclamation-triangle"></i> GCC-like compilers only
-
-Tested on GCC and Clang.
-</div>
-
-## Introduction
-
-[ccache](https://ccache.samba.org) speeds up compilation times by caching object files and reusing them on subsequent builds. This even works for complete rebuilds (i.e. deleting the full build-directory). If ccache is found on the system it is automatically used.
-
-To disable caching with ccache:
-
-```bash
-cmake . -DOGS_DISABLE_CCACHE=ON
-```
-
-## Usage on eve
-
-Just load the module:
-
-```bash
-module load /global/apps/modulefiles/ccache/3.3.3
-```
-- 
GitLab