From 6405abbc753352feaf3c4642036fb40d8b8ed2b6 Mon Sep 17 00:00:00 2001 From: Michal Jenikovsky Date: Sun, 7 Jul 2024 18:38:26 +0200 Subject: [PATCH] build: added support for ccache Signed-off-by: Michal Jenikovsky --- samples/Makefile | 1 + samples/ccache.cmake | 10 ++++++++++ samples/ps2dev.cmake | 2 ++ samples/ps2dev_iop.cmake | 2 ++ 4 files changed, 15 insertions(+) create mode 100644 samples/ccache.cmake diff --git a/samples/Makefile b/samples/Makefile index 22fbb39b9904..e847aaa7cad1 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -28,6 +28,7 @@ release-samples: cp -f Makefile.iopglobal_sample $(SAMPLES_TARGET)/Makefile.iopglobal cp -f ps2dev.cmake $(SHARE_TARGET)/ps2dev.cmake cp -f ps2dev_iop.cmake $(SHARE_TARGET)/ps2dev_iop.cmake + cp -f ccache.cmake $(SHARE_TARGET)/ccache.cmake release-clean: rm -f -r $(SAMPLES_TARGET) diff --git a/samples/ccache.cmake b/samples/ccache.cmake new file mode 100644 index 000000000000..d2c88938e963 --- /dev/null +++ b/samples/ccache.cmake @@ -0,0 +1,10 @@ +find_program(CCACHE_FOUND "ccache") +set(CCACHE_SUPPORT ON CACHE BOOL "Enable ccache support") +if (CCACHE_FOUND AND CCACHE_SUPPORT) + if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + # without this compiler messages in `make` backend would be uncolored + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=auto") + endif() + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "ccache") + set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "ccache") +endif(CCACHE_FOUND) diff --git a/samples/ps2dev.cmake b/samples/ps2dev.cmake index f8feb3d51c04..555fd5d3d388 100644 --- a/samples/ps2dev.cmake +++ b/samples/ps2dev.cmake @@ -53,3 +53,5 @@ SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-nostartfiles -Wl,-r -Wl,-d") SET(PS2 TRUE) SET(PLATFORM_PS2 TRUE) SET(EE TRUE) + +INCLUDE(ccache.cmake) diff --git a/samples/ps2dev_iop.cmake b/samples/ps2dev_iop.cmake index 8e2e54938dac..7cf1f108b773 100644 --- a/samples/ps2dev_iop.cmake +++ b/samples/ps2dev_iop.cmake @@ -78,3 +78,5 @@ ENDFUNCTION() SET(PLATFORM_PS2 TRUE) SET(IOP TRUE) SET(PS2 TRUE) + +INCLUDE(ccache.cmake)