From a4df4c6079135c9170a00099ab7f3b3b18178f28 Mon Sep 17 00:00:00 2001 From: Linus_Probert Date: Fri, 16 Feb 2018 10:13:16 +0100 Subject: [PATCH] Adds ccache to build This is mostly for fun and because I want to see how it works in travis. --- .travis.yml | 1 + CMakeLists.txt | 1 + cmake/FindCCache.cmake | 17 +++++++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 cmake/FindCCache.cmake diff --git a/.travis.yml b/.travis.yml index 910c0db..0b849bf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ sudo: required dist: trusty language: c +cache: ccache compiler: - gcc - clang diff --git a/CMakeLists.txt b/CMakeLists.txt index b70368d..34b4e2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ include(cmake/FindSDL2.cmake) include(cmake/FindSDL2_image.cmake) include(cmake/FindSDL2_ttf.cmake) include(cmake/FindSDL2_mixer.cmake) +include(cmake/FindCCache.cmake) if (NOT WIN32) include(FindX11) diff --git a/cmake/FindCCache.cmake b/cmake/FindCCache.cmake new file mode 100644 index 0000000..0d1985f --- /dev/null +++ b/cmake/FindCCache.cmake @@ -0,0 +1,17 @@ +# FindCCache +# ---------- +# Finds ccache and sets it up as compiler wrapper. +# This should ideally be called before the call to project(). +# +# See: https://crascit.com/2016/04/09/using-ccache-with-cmake/ + +find_program(CCACHE_PROGRAM ccache) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(CCache REQUIRED_VARS CCACHE_PROGRAM) + +if(CCACHE_FOUND) + # Supports Unix Makefiles and Ninja + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}") + set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCACHE_PROGRAM}") +endif() \ No newline at end of file