From d74c6b5ca52451ff1fb683b22083da86005f229b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Vanda=C3=ABle?= Date: Thu, 8 Jan 2026 16:37:38 +0100 Subject: [PATCH] CCache: Add support for Objective-C/Objective-C++ --- CMake/CCache.cmake | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/CMake/CCache.cmake b/CMake/CCache.cmake index 37ad51ee09..cfb29e2101 100644 --- a/CMake/CCache.cmake +++ b/CMake/CCache.cmake @@ -1,17 +1,13 @@ find_program(CCACHE_BIN NAMES ccache sccache) if(CCACHE_BIN) - # Official ccache recommendation is to set CMAKE_C(XX)_COMPILER_LAUNCHER - if (NOT CMAKE_C_COMPILER_LAUNCHER MATCHES "ccache") - list(INSERT CMAKE_C_COMPILER_LAUNCHER 0 "${CCACHE_BIN}") - endif() - - if (NOT CMAKE_CXX_COMPILER_LAUNCHER MATCHES "ccache") - list(INSERT CMAKE_CXX_COMPILER_LAUNCHER 0 "${CCACHE_BIN}") - endif() - - # ccache uses -I when compiling without preprocessor, which makes clang complain. - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Qunused-arguments -fcolor-diagnostics") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments -fcolor-diagnostics") - endif() + set(_CCACHE_SUPPORTED_LAUCHERS C CXX OBJC OBJCXX) + foreach(LAUNCHER ${_CCACHE_SUPPORTED_LAUCHERS}) + if (NOT CMAKE_${LAUNCHER}_COMPILER_LAUNCHER MATCHES "ccache") + list(INSERT CMAKE_${LAUNCHER}_COMPILER_LAUNCHER 0 ${CCACHE_BIN}) + endif() + # ccache uses -I when compiling without preprocessor, which makes clang complain. + if("${CMAKE_${LAUNCHER}_COMPILER_ID}" MATCHES "Clang") + set(CMAKE_${LAUNCHER}_FLAGS "${CMAKE_${LAUNCHER}_FLAGS} -Qunused-arguments -fcolor-diagnostics") + endif() + endforeach() endif()