[PATCH] cmake: switch ccache handling to use cmake's launcher

Rosen Penev rosenp at gmail.com
Fri Dec 18 18:27:17 EST 2020


A recent cmake version bump broke ccache handling of cmake files. This
commit switches it to use CMAKE_X_COMPILER_LAUNCHER instead of the
hacky ARG1 stuff.

Originally posted by Hirokazu Morikawa as a diff:
https://github.com/openwrt/openwrt/commit/bfc433efd4a0c6875a92981d1bd2a5e3e60c61c6#commitcomment-45228331

Signed-off-by: Rosen Penev <rosenp at gmail.com>
---
 include/cmake.mk | 39 +++++++++++++++------------------------
 1 file changed, 15 insertions(+), 24 deletions(-)

diff --git a/include/cmake.mk b/include/cmake.mk
index 0a20530a16..cff62fb535 100644
--- a/include/cmake.mk
+++ b/include/cmake.mk
@@ -19,27 +19,20 @@ else
 endif
 
 ifeq ($(CONFIG_CCACHE),)
- CMAKE_C_COMPILER:=$(call cmake_tool,$(TARGET_CC))
- CMAKE_CXX_COMPILER:=$(call cmake_tool,$(TARGET_CXX))
- CMAKE_C_COMPILER_ARG1:=
- CMAKE_CXX_COMPILER_ARG1:=
-
- CMAKE_HOST_C_COMPILER:=$(HOSTCC)
- CMAKE_HOST_CXX_COMPILER:=$(HOSTCXX)
- CMAKE_HOST_C_COMPILER_ARG1:=
- CMAKE_HOST_CXX_COMPILER_ARG1:=
+  CMAKE_C_COMPILER_LAUNCHER:=
+  CMAKE_CXX_COMPILER_LAUNCHER:=
 else
   CCACHE:=$(STAGING_DIR_HOST)/bin/ccache
-  CMAKE_C_COMPILER:=$(CCACHE)
-  CMAKE_C_COMPILER_ARG1:=$(TARGET_CC_NOCACHE)
-  CMAKE_CXX_COMPILER:=$(CCACHE)
-  CMAKE_CXX_COMPILER_ARG1:=$(TARGET_CXX_NOCACHE)
-
-  CMAKE_HOST_C_COMPILER:=$(CCACHE)
-  CMAKE_HOST_C_COMPILER_ARG1:=$(HOSTCC_NOCACHE)
-  CMAKE_HOST_CXX_COMPILER:=$(CCACHE)
-  CMAKE_HOST_CXX_COMPILER_ARG1:=$(HOSTCXX_NOCACHE)
+  CMAKE_C_COMPILER_LAUNCHER:=$(CCACHE)
+  CMAKE_CXX_COMPILER_LAUNCHER:=$(CCACHE)
 endif
+
+CMAKE_C_COMPILER:=$(call cmake_tool,$(TARGET_CC_NOCACHE))
+CMAKE_CXX_COMPILER:=$(call cmake_tool,$(TARGET_CXX_NOCACHE))
+
+CMAKE_HOST_C_COMPILER:=$(HOSTCC_NOCACHE)
+CMAKE_HOST_CXX_COMPILER:=$(HOSTCXX_NOCACHE)
+
 CMAKE_AR:=$(call cmake_tool,$(TARGET_AR))
 CMAKE_NM:=$(call cmake_tool,$(TARGET_NM))
 CMAKE_RANLIB:=$(call cmake_tool,$(TARGET_RANLIB))
@@ -61,12 +54,11 @@ define Build/Configure/Default
 			-DCMAKE_BUILD_TYPE=Release \
 			-DCMAKE_C_FLAGS_RELEASE="-DNDEBUG" \
 			-DCMAKE_CXX_FLAGS_RELEASE="-DNDEBUG" \
+			-DCMAKE_C_COMPILER_LAUNCHER="$(CMAKE_C_COMPILER_LAUNCHER)" \
 			-DCMAKE_C_COMPILER="$(CMAKE_C_COMPILER)" \
-			-DCMAKE_C_COMPILER_ARG1="$(CMAKE_C_COMPILER_ARG1)" \
+			-DCMAKE_CXX_COMPILER_LAUNCHER="$(CMAKE_CXX_COMPILER_LAUNCHER)" \
 			-DCMAKE_CXX_COMPILER="$(CMAKE_CXX_COMPILER)" \
-			-DCMAKE_CXX_COMPILER_ARG1="$(CMAKE_CXX_COMPILER_ARG1)" \
 			-DCMAKE_ASM_COMPILER="$(CMAKE_C_COMPILER)" \
-			-DCMAKE_ASM_COMPILER_ARG1="$(CMAKE_C_COMPILER_ARG1)" \
 			-DCMAKE_EXE_LINKER_FLAGS:STRING="$(TARGET_LDFLAGS)" \
 			-DCMAKE_MODULE_LINKER_FLAGS:STRING="$(TARGET_LDFLAGS) $(CMAKE_SHARED_LDFLAGS)" \
 			-DCMAKE_SHARED_LINKER_FLAGS:STRING="$(TARGET_LDFLAGS) $(CMAKE_SHARED_LDFLAGS)" \
@@ -107,12 +99,11 @@ define Host/Configure/Default
 		LDFLAGS="$(HOST_LDFLAGS)" \
 		cmake \
 			-DCMAKE_BUILD_TYPE=Release \
+			-DCMAKE_C_COMPILER_LAUNCHER="$(CMAKE_C_COMPILER_LAUNCHER)" \
 			-DCMAKE_C_COMPILER="$(CMAKE_HOST_C_COMPILER)" \
-			-DCMAKE_C_COMPILER_ARG1="$(CMAKE_HOST_C_COMPILER_ARG1)" \
+			-DCMAKE_CXX_COMPILER_LAUNCHER="$(CMAKE_CXX_COMPILER_LAUNCHER)" \
 			-DCMAKE_CXX_COMPILER="$(CMAKE_HOST_CXX_COMPILER)" \
-			-DCMAKE_CXX_COMPILER_ARG1="$(CMAKE_HOST_CXX_COMPILER_ARG1)" \
 			-DCMAKE_ASM_COMPILER="$(CMAKE_HOST_C_COMPILER)" \
-			-DCMAKE_ASM_COMPILER_ARG1="$(CMAKE_HOST_C_COMPILER_ARG1)" \
 			-DCMAKE_C_FLAGS_RELEASE="-DNDEBUG" \
 			-DCMAKE_CXX_FLAGS_RELEASE="-DNDEBUG" \
 			-DCMAKE_EXE_LINKER_FLAGS:STRING="$(HOST_LDFLAGS)" \
-- 
2.29.2




More information about the openwrt-devel mailing list