From cfcd6e22bb2081fa9f730c4ee0e07d04b1c8fe55 Mon Sep 17 00:00:00 2001 From: Jxtopher <39927513+Jxtopher@users.noreply.github.com> Date: Fri, 28 Mar 2025 22:30:30 +0100 Subject: [PATCH] Ccache setup The goal is to speed up recompilation using ccache. Ccache is a tool that speeds up recompilation of C/C++ code. It does this by caching the results of previous compilations. When you recompile code, ccache checks if it has already compiled the same code with the same compiler flags. If so, it uses the cached result instead of recompiling. --- .github/workflows/build_ubuntu_debug.yml | 9 ++++++++- CMakeLists.txt | 11 +++++++++++ README.md | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_ubuntu_debug.yml b/.github/workflows/build_ubuntu_debug.yml index b68744cb2..58aac6a42 100644 --- a/.github/workflows/build_ubuntu_debug.yml +++ b/.github/workflows/build_ubuntu_debug.yml @@ -16,8 +16,15 @@ jobs: compiler: [g++-10, g++-9, g++-8, g++-7, clang-6, clang-7, clang-8, clang-9, clang-10, clang-11, clang-12] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + - name: Caching objects + id: cache-objects + uses: actions/cache@v4 + with: + path: ~/.cache/ccache + key: ${{ runner.os }}-${{env.BUILD_TYPE}}-${{ matrix.compiler }}-objects + - name: Install Dependencies shell: bash run: | diff --git a/CMakeLists.txt b/CMakeLists.txt index 5bec9ae43..1b364f35f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,17 @@ project("ParadisEO" ## Language set(CMAKE_CXX_STANDARD 17) +## ccache +find_program(CCACHE_PROGRAM ccache) + +if (CCACHE_PROGRAM) + message(NOTICE "-- ccache is enabled (found here: ${CCACHE_PROGRAM})") + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "\"${CCACHE_PROGRAM}\"") + set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "\"${CCACHE_PROGRAM}\"") +else () + message(NOTICE "-- ccache has not been found") +endif () + ###################################################################################### ### 2) Check dependencies diff --git a/README.md b/README.md index 686b08334..ff158606d 100644 --- a/README.md +++ b/README.md @@ -211,6 +211,7 @@ If you `ENABLE_CMAKE_EXAMPLE`, it will also build the examples. If may want to make build scripts more verbose (especially when building the doc) by enabling `CMAKE_VERBOSE_MAKEFILE`. +If `ccache` installed in your environment, library recompilation times can be significantly reduced. To clear all cached objects, execute `ccache -C`. ## Licenses