diff --git a/CMakeLists.txt b/CMakeLists.txt index 082596090c26bb7d3205054ee6b459e31adbc90e..2b11b5f42e8259cc8949c0405bb07a9482d6f81f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,7 +71,6 @@ include(ConanSetup) include(CompilerSetup) include(JobPools) include(Find) -include(CLCacheSetup) include(packaging/PackagingDependencies) include(DependenciesExternalProject) include(Dependencies) diff --git a/scripts/cmake/CLCacheSetup.cmake b/scripts/cmake/CLCacheSetup.cmake deleted file mode 100644 index ecf2bed9ee4e26a66e45f3af2e6339d2e036e75e..0000000000000000000000000000000000000000 --- a/scripts/cmake/CLCacheSetup.cmake +++ /dev/null @@ -1,13 +0,0 @@ -if(NOT WIN32 OR NOT CLCACHE_TOOL_PATH OR OGS_DISABLE_COMPILER_CACHE) - return() -endif() - -file(DOWNLOAD - https://gitlab.com/timblechmann/clcache-launcher/uploads/c11842f963af3543b448cb400ed5fce9/clcache-launcher.exe - ${PROJECT_BINARY_DIR}/clcache-launcher.exe -) - -set(CMAKE_C_COMPILER_LAUNCHER ${PROJECT_BINARY_DIR}/clcache-launcher.exe) -set(CMAKE_CXX_COMPILER_LAUNCHER ${PROJECT_BINARY_DIR}/clcache-launcher.exe) - -message(STATUS "clcache enabled! (${CLCACHE_TOOL_PATH})") diff --git a/scripts/cmake/Dependencies.cmake b/scripts/cmake/Dependencies.cmake index e5405a1ec9643075a423366319619db9093f7df3..9cc8727c2505a6c0528df7c56c047f6b37bc469e 100644 --- a/scripts/cmake/Dependencies.cmake +++ b/scripts/cmake/Dependencies.cmake @@ -1,6 +1,6 @@ set(CMAKE_FOLDER ThirdParty) -# ccache +# ccache, on Windows requires https://github.com/cristianadam/ccache/releases 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") @@ -12,6 +12,15 @@ if(NOT WIN32 AND CCACHE_TOOL_PATH AND NOT OGS_DISABLE_COMPILER_CACHE) VERSION 1.2.2 OPTIONS "USE_CCACHE ON" ) +elseif( + WIN32 + AND CCACHE_TOOL_PATH + AND NOT OGS_DISABLE_COMPILER_CACHE + AND "${CMAKE_GENERATOR}" STREQUAL "Ninja" +) + set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_TOOL_PATH} CACHE STRING "" FORCE) + set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_TOOL_PATH} CACHE STRING "" FORCE) + message(STATUS "Using ccache (${CCACHE_TOOL_PATH}).") endif() if(OGS_BUILD_TESTING) diff --git a/scripts/cmake/Find.cmake b/scripts/cmake/Find.cmake index f6dba5a458236fb1f8d8939a299bba6f1d64545a..80e22723bc6d4ad094dfa3a4c3cb9d339cb2261c 100644 --- a/scripts/cmake/Find.cmake +++ b/scripts/cmake/Find.cmake @@ -36,13 +36,7 @@ find_program(CURL_TOOL_PATH curl DOC "The curl-tool") find_program(S3CMD_TOOL_PATH s3cmd DOC "S3cmd tool for uploading to Amazon S3") -if(WIN32) - if(${CMAKE_GENERATOR} STREQUAL "Ninja") - find_program(CLCACHE_TOOL_PATH clcache) - endif() -else() - find_program(CCACHE_TOOL_PATH ccache) -endif() +find_program(CCACHE_TOOL_PATH ccache) # Tools for web find_program( diff --git a/web/content/docs/devguide/advanced/compiler-cache.md b/web/content/docs/devguide/advanced/compiler-cache.md index 32c8e22302d55aed100915028fb912eb6fde01a5..0bc704a568fdffc00cc5467283721eedeaf2a5a1 100644 --- a/web/content/docs/devguide/advanced/compiler-cache.md +++ b/web/content/docs/devguide/advanced/compiler-cache.md @@ -13,13 +13,15 @@ aliases = ["/docs/devguide/advanced/using-ccache"] ## 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. +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). The compiler cache [ccache](https://ccache.samba.org) 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. +Install it with your package manager, e.g.: -You can check cache hits with `ccache -s`. +```bash +sudo apt install ccache +``` ## Usage on eve @@ -33,28 +35,23 @@ module load /global/apps/modulefiles/ccache/3.3.3 <div class='mac'> -See Linux-tab! +```bash +brew install ccache +``` </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): +Windows support in ccache is not yet in the main ccache development line. Please install ccache from https://github.com/cristianadam/ccache/releases. -```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=. -``` +Just extract the archive and put the `ccache.exe` into the `PATH`. -You may want to increase the cache size (to 10 GB in this case): - -```bash -clcache -M 10000000000 -``` +</div> -You can check cache hits with `clcache -s`. +You may want to change the cache directory (environment variable `CCACHE_DIR`) or increase the cache size (e.g. `ccache -M 10G` or `CCACHE_MAXSIZE`). See the [ccache docs](https://ccache.dev/manual/4.3.html#_configuration) for configuration instructions. -</div> +You can check cache hit statistics with `ccache -s`. To disable caching: