Cmake: Add option to disable ccache

Allow ccache usage to be disabled through the ENABLE_CCACHE CMake
option, while preserving the existing automatic detection and
Emscripten exclusion behavior.

This is useful for builds where ccache is available but undesirable,
(like Coverity) and provides clear configuration messages when
ccache is skipped.

Signed-off-by: Robin Getz <rgetz503@gmail.com>
This commit is contained in:
Robin Getz
2026-08-30 14:49:41 -04:00
parent 262ad92a4b
commit cb24cf0aff
+9 -2
View File
@@ -260,8 +260,10 @@ if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git/")
endif()
endif()
find_program(CCACHE "ccache")
if(CCACHE AND NOT EMSCRIPTEN)
option(ENABLE_CCACHE "Enable ccache for faster builds" ON)
if (ENABLE_CCACHE)
find_program(CCACHE "ccache")
if(CCACHE AND NOT EMSCRIPTEN)
message(STATUS "Using ccache ${CCACHE}")
set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE})
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE})
@@ -269,6 +271,11 @@ if(CCACHE AND NOT EMSCRIPTEN)
set(CMAKE_OBJCXX_COMPILER_LAUNCHER ${CCACHE})
endif()
set(ENV{CCACHE_SLOPPINESS} pch_defines,time_macros)
else()
message(STATUS "Skipping ccache")
endif()
else()
message(STATUS "Disabled ccache")
endif()
set(sdrangel_VERSION "${sdrangel_VERSION_MAJOR}.${sdrangel_VERSION_MINOR}.${sdrangel_VERSION_PATCH}${sdrangel_VERSION_SUFFIX}" CACHE INTERNAL "")