Skip to content
Snippets Groups Projects
Commit e7b1b425 authored by Lars Bilke's avatar Lars Bilke Committed by Dmitri Naumov
Browse files

[cmake] Renamed OGS_DISABLE_CLCACHE to OGS_DISABLE_COMPILER_CACHE.

[web] Added unified docs for ccache and clcache.
parent 03d2c78f
No related branches found
No related tags found
No related merge requests found
...@@ -33,11 +33,7 @@ option(OGS_USE_CONAN "Should Conan package manager be used?" ON) ...@@ -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, \ set(OGS_CONAN_BUILD "missing" CACHE STRING "Possible values: all, missing, \
never or list of libs to build" never or list of libs to build"
) )
if(WIN32) option(OGS_DISABLE_COMPILER_CACHE "Disables compiler cache." OFF)
option(OGS_DISABLE_CLCACHE "Disables clcache compiler cache." OFF)
else()
option(OGS_DISABLE_CCACHE "Disables ccache compiler cache." OFF)
endif()
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.16) if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.16)
option(OGS_USE_UNITY_BUILDS "Enables Unity builds for faster compilation." option(OGS_USE_UNITY_BUILDS "Enables Unity builds for faster compilation."
ON ON
......
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() return()
endif() endif()
......
...@@ -425,7 +425,7 @@ cpm_licenses_create_disclaimer_target( ...@@ -425,7 +425,7 @@ cpm_licenses_create_disclaimer_target(
) )
# ccache # 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") set(CCACHE_OPTIONS "CCACHE_SLOPPINESS=pch_defines,time_macros")
if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang|AppleClang") if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang|AppleClang")
list(APPEND CCACHE_OPTIONS "CCACHE_CPP2=true") list(APPEND CCACHE_OPTIONS "CCACHE_CPP2=true")
......
+++
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
```
...@@ -55,7 +55,7 @@ singularity pull docker://registry.opengeosys.org/ogs/ogs/gcc # Downloads the im ...@@ -55,7 +55,7 @@ singularity pull docker://registry.opengeosys.org/ogs/ogs/gcc # Downloads the im
singularity shell gcc_latest.sif singularity shell gcc_latest.sif
[Now inside the container] [Now inside the container]
mkdir build; cd build 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 ninja
./bin/ogs ./bin/ogs
``` ```
......
+++
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
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment