Skip to content

Commit e4aaad6

Browse files
committed
Add option to enable ccache to build
- Add ENABLE_CCACHE flag to cmake - Install ccache in dev container - Always enable caching in CMakePresets.json
1 parent 375740b commit e4aaad6

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ if(BUILD_RESOURCES)
3131
set(BUILD_RESOURCES true)
3232
endif()
3333

34+
if(ENABLE_CCACHE)
35+
include(cmake/ccache.cmake)
36+
endif()
37+
3438
set(TARGET_DEVICE "PINETIME" CACHE STRING "Target device")
3539
set_property(CACHE TARGET_DEVICE PROPERTY STRINGS PINETIME MOY_TFK5 MOY_TIN5 MOY_TON5 MOY_UNK)
3640

CMakePresets.json

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
"TARGET_DEVICE": {
3232
"type": "STRING",
3333
"value": "PINETIME"
34+
},
35+
"ENABLE_CCACHE": {
36+
"type": "BOOL",
37+
"value": true
3438
}
3539
}
3640
},

cmake/ccache.cmake

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
find_program(CCACHE_EXECUTABLE ccache)
2+
3+
if (CCACHE_EXECUTABLE)
4+
message(STATUS "Activating ccache compiler cache.")
5+
set(ccacheEnv
6+
CCACHE_SLOPPINESS=pch_defines
7+
)
8+
foreach (lang IN ITEMS C CXX)
9+
set(CMAKE_${lang}_COMPILER_LAUNCHER
10+
${CMAKE_COMMAND} -E env ${ccacheEnv} ${CCACHE_EXECUTABLE}
11+
)
12+
endforeach ()
13+
message(WARNING "Ccache could not be activated because ccache executable was not found.")
14+
endif ()

docker/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ RUN apt-get update -qq \
1212
# x86_64 / generic packages
1313
bash \
1414
build-essential \
15+
ccache \
1516
cmake \
1617
git \
1718
make \

0 commit comments

Comments
 (0)