From 26e7ba7a3fbef26a1c53b0ee9507210609e3efd4 Mon Sep 17 00:00:00 2001 From: Roy Shilkrot Date: Mon, 25 Nov 2024 12:31:57 -0500 Subject: [PATCH] Enable ccache support in CMake build scripts for improved build performance --- .github/workflows/build-project.yaml | 4 ++-- cmake/BuildCTranslate2.cmake | 7 +++++++ cmake/BuildSentencepiece.cmake | 7 +++++++ cmake/BuildWhispercpp.cmake | 7 +++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-project.yaml b/.github/workflows/build-project.yaml index cbe9fa6..91cabe1 100644 --- a/.github/workflows/build-project.yaml +++ b/.github/workflows/build-project.yaml @@ -115,9 +115,9 @@ jobs: id: ccache-cache with: path: ${{ github.workspace }}/.ccache - key: ${{ runner.os }}-ccache-${{ needs.check-event.outputs.config }} + key: ${{ runner.os }}-ccache-${{ needs.check-event.outputs.config }}-${{ matrix.architecture }} restore-keys: | - ${{ runner.os }}-ccache- + ${{ runner.os }}-ccache-${{ matrix.architecture }}- - name: Set Up Codesigning 🔑 uses: ./.github/actions/setup-macos-codesigning diff --git a/cmake/BuildCTranslate2.cmake b/cmake/BuildCTranslate2.cmake index 0d60561..4c21c7f 100644 --- a/cmake/BuildCTranslate2.cmake +++ b/cmake/BuildCTranslate2.cmake @@ -50,6 +50,13 @@ elseif(WIN32) file(GLOB CT2_DLLS ${ctranslate2_fetch_SOURCE_DIR}/bin/*.dll) install(FILES ${CT2_DLLS} DESTINATION "obs-plugins/64bit") else() + # Enable ccache if available + find_program(CCACHE_PROGRAM ccache) + if(CCACHE_PROGRAM) + set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_PROGRAM}) + set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_PROGRAM}) + endif() + # build cpu_features from source set(CPU_FEATURES_VERSION "0.9.0") set(CPU_FEATURES_URL "https://github.com/google/cpu_features.git") diff --git a/cmake/BuildSentencepiece.cmake b/cmake/BuildSentencepiece.cmake index 024283e..4df4f6d 100644 --- a/cmake/BuildSentencepiece.cmake +++ b/cmake/BuildSentencepiece.cmake @@ -27,6 +27,13 @@ elseif(WIN32) else() + # Enable ccache if available + find_program(CCACHE_PROGRAM ccache) + if(CCACHE_PROGRAM) + set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_PROGRAM}) + set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_PROGRAM}) + endif() + set(SP_URL "https://github.com/google/sentencepiece.git" CACHE STRING "URL of sentencepiece repository") diff --git a/cmake/BuildWhispercpp.cmake b/cmake/BuildWhispercpp.cmake index b51332e..5f1e628 100644 --- a/cmake/BuildWhispercpp.cmake +++ b/cmake/BuildWhispercpp.cmake @@ -102,6 +102,13 @@ elseif(WIN32) file(GLOB WHISPER_DLLS ${whispercpp_fetch_SOURCE_DIR}/bin/*.dll) install(FILES ${WHISPER_DLLS} DESTINATION "obs-plugins/64bit") else() + # Enable ccache if available + find_program(CCACHE_PROGRAM ccache) + if(CCACHE_PROGRAM) + set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_PROGRAM}) + set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_PROGRAM}) + endif() + if(${CMAKE_BUILD_TYPE} STREQUAL Release OR ${CMAKE_BUILD_TYPE} STREQUAL RelWithDebInfo) set(Whispercpp_BUILD_TYPE Release) else()