feat(cmakev2/idf): enable ccache if requested

Enable ccache if CCACHE_ENABLE is set.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
Frantisek Hrbata
2025-11-04 07:48:14 +01:00
parent 8840aa0488
commit 81c7c79af5
+22
View File
@@ -316,6 +316,25 @@ function(__init_toolchain)
idf_build_set_property(IDF_TOOLCHAIN_FILE "${toolchain_file}")
endfunction()
#[[
__init_ccache()
Enable ccache if requested through CCACHE_ENABLE.
#]]
function(__init_ccache)
if(NOT CCACHE_ENABLE)
return()
endif()
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
idf_msg("ccache will be used for faster recompilation")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
else()
idf_warn("enabled ccache in build but ccache program not found")
endif()
endfunction()
#[[
__init_components()
@@ -565,6 +584,9 @@ __init_idf_target()
# Set IDF_TOOLCHAIN, IDF_TOOLCHAIN_FILE and CMAKE_TOOLCHAIN_FILE.
__init_toolchain()
# Enable ccache if requested.
__init_ccache()
# Discover and initialize components.
__init_components()