Skip to content

Commit 0c345be

Browse files
committed
cmake: Support sccache
Signed-off-by: Zack Cerza <[email protected]>
1 parent 5177c58 commit 0c345be

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,21 @@ if(WITH_CCACHE)
8383
endif()
8484
endif(WITH_CCACHE)
8585

86+
option(WITH_SCCACHE "Build with sccache.")
87+
if(WITH_SCCACHE)
88+
if(CMAKE_C_COMPILER_LAUNCHER OR CMAKE_CXX_COMPILER_LAUNCHER)
89+
message(WARNING "Compiler launcher already set. stop configuring sccache")
90+
else()
91+
find_program(SCCACHE_EXECUTABLE sccache)
92+
if(NOT SCCACHE_EXECUTABLE)
93+
message(FATAL_ERROR "Can't find sccache. Is it installed?")
94+
endif()
95+
message(STATUS "Building with sccache: ${SCCACHE_EXECUTABLE}, SCCACHE_CONF=$ENV{SCCACHE_CONF}")
96+
set(CMAKE_C_COMPILER_LAUNCHER ${SCCACHE_EXECUTABLE})
97+
set(CMAKE_CXX_COMPILER_LAUNCHER ${SCCACHE_EXECUTABLE})
98+
endif()
99+
endif(WITH_SCCACHE)
100+
86101
option(WITH_MANPAGE "Build man pages." ON)
87102
if(WITH_MANPAGE)
88103
find_program(SPHINX_BUILD

do_cmake.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ fi
5858

5959
ARGS+=" -DWITH_PYTHON3=${PYBUILD}"
6060

61-
if type ccache > /dev/null 2>&1 ; then
61+
if type sccache > /dev/null 2>&1 ; then
62+
echo "enabling sccache"
63+
ARGS+=" -DWITH_SCCACHE=ON"
64+
elif type ccache > /dev/null 2>&1 ; then
6265
echo "enabling ccache"
6366
ARGS+=" -DWITH_CCACHE=ON"
6467
fi

0 commit comments

Comments
 (0)