package/pkg-cmake.mk: add ccache support for host packages
authorSamuel Martin <s.martin49@gmail.com>
Sun, 14 Dec 2014 19:12:01 +0000 (20:12 +0100)
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Sun, 21 Dec 2014 21:50:45 +0000 (22:50 +0100)
This ccache support for host-cmake-package uses the same logic as the
one done for the target packages in the toolchainfile.cmake file.

[Thomas: fix lots of mistakes.]

Signed-off-by: Samuel Martin <s.martin49@gmail.com>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
package/pkg-cmake.mk

index 231d0ba0af5e8904957846abb9fde5453929d2fb..1037513e97c4923515f2917c453308a590791178 100644 (file)
 #
 ################################################################################
 
+# Set compiler variables.
+ifeq ($(BR2_CCACHE),y)
+CMAKE_HOST_C_COMPILER="$(HOST_DIR)/usr/bin/ccache"
+CMAKE_HOST_CXX_COMPILER="$(HOST_DIR)/usr/bin/ccache"
+CMAKE_HOST_C_COMPILER_ARG1="$(HOSTCC_NOCCACHE)"
+CMAKE_HOST_CXX_COMPILER_ARG1="$(HOSTCXX_NOCCACHE)"
+else
+CMAKE_HOST_C_COMPILER="$$(HOSTCC)"
+CMAKE_HOST_CXX_COMPILER="$$(HOSTCXX)"
+endif
+
 ################################################################################
 # inner-cmake-package -- defines how the configuration, compilation and
 # installation of a CMake package should be done, implements a few hooks to
@@ -95,6 +106,13 @@ define $(2)_CONFIGURE_CMDS
                -DCMAKE_C_FLAGS="$$(HOST_CFLAGS)" \
                -DCMAKE_CXX_FLAGS="$$(HOST_CXXFLAGS)" \
                -DCMAKE_EXE_LINKER_FLAGS="$$(HOST_LDFLAGS)" \
+               -DCMAKE_ASM_COMPILER="$$(HOSTAS)" \
+               -DCMAKE_C_COMPILER="$$(CMAKE_HOST_C_COMPILER)" \
+               -DCMAKE_CXX_COMPILER="$$(CMAKE_HOST_CXX_COMPILER)" \
+               $(if $$(CMAKE_HOST_C_COMPILER_ARG1),\
+                       -DCMAKE_C_COMPILER_ARG1="$$(CMAKE_HOST_C_COMPILER_ARG1)" \
+                       -DCMAKE_CXX_COMPILER_ARG1="$$(CMAKE_HOST_CXX_COMPILER_ARG1)" \
+               ) \
                -DCMAKE_COLOR_MAKEFILE=OFF \
                -DBUILD_DOC=OFF \
                -DBUILD_DOCS=OFF \