cmake: Support sccache

Signed-off-by: Zack Cerza <zack@redhat.com>
This commit is contained in:
Zack Cerza 2024-03-14 15:24:30 -06:00
parent 5177c5855f
commit 0c345becf8
2 changed files with 19 additions and 1 deletions

View File

@ -83,6 +83,21 @@ if(WITH_CCACHE)
endif()
endif(WITH_CCACHE)
option(WITH_SCCACHE "Build with sccache.")
if(WITH_SCCACHE)
if(CMAKE_C_COMPILER_LAUNCHER OR CMAKE_CXX_COMPILER_LAUNCHER)
message(WARNING "Compiler launcher already set. stop configuring sccache")
else()
find_program(SCCACHE_EXECUTABLE sccache)
if(NOT SCCACHE_EXECUTABLE)
message(FATAL_ERROR "Can't find sccache. Is it installed?")
endif()
message(STATUS "Building with sccache: ${SCCACHE_EXECUTABLE}, SCCACHE_CONF=$ENV{SCCACHE_CONF}")
set(CMAKE_C_COMPILER_LAUNCHER ${SCCACHE_EXECUTABLE})
set(CMAKE_CXX_COMPILER_LAUNCHER ${SCCACHE_EXECUTABLE})
endif()
endif(WITH_SCCACHE)
option(WITH_MANPAGE "Build man pages." ON)
if(WITH_MANPAGE)
find_program(SPHINX_BUILD

View File

@ -58,7 +58,10 @@ fi
ARGS+=" -DWITH_PYTHON3=${PYBUILD}"
if type ccache > /dev/null 2>&1 ; then
if type sccache > /dev/null 2>&1 ; then
echo "enabling sccache"
ARGS+=" -DWITH_SCCACHE=ON"
elif type ccache > /dev/null 2>&1 ; then
echo "enabling ccache"
ARGS+=" -DWITH_CCACHE=ON"
fi