From b13454eeb43137b0fed03b91688448d3a9c4ed8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfram=20R=C3=B6sler?= Date: Sun, 9 Jun 2019 22:10:58 +0200 Subject: [PATCH] Compile with Compiler Cache (ccache) if it's installed Install with `sudo apt install ccache`. Makes building a huge lot faster, especially when switching branches. Nothing happens if ccache is not installed. Example: (measured on my laptop) ``` $ ccache -C # clear the cache $ rm -fr build $ cd build $ cmake -DWITH_XC_ALL=ON -DCMAKE_BUILD_TYPE=Release .. $ time make -j4 ... real 5m8,817s user 16m47,107s sys 1m38,808s $ rm -fr ../build/* $ cmake -DWITH_XC_ALL=ON -DCMAKE_BUILD_TYPE=Release .. $ time make -j4 ... real 0m32,571s user 1m0,253s sys 0m24,069s ``` --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ca8b0774..22646098 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,13 @@ string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) +# Use the Compiler Cache (ccache) if it is installed +# (install with: sudo apt get ccache) +find_program (CCACHE_FOUND ccache) +if (CCACHE_FOUND) + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) +endif (CCACHE_FOUND) + # Support Visual Studio Code include(CMakeToolsHelpers OPTIONAL)