From 8e5e6ddc5e526abc84d162f24decfa7be78887b1 Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Tue, 8 Nov 2016 11:11:14 -0800 Subject: CMake: Enable ccache for gcc and clang. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add an option to check for and use ccache. Disable it by default. Change-Id: Ifc928d22715b7e06e53115455b31dbeaf2ee8332 Reviewed-on: https://code.wireshark.org/review/18715 Petri-Dish: Gerald Combs Reviewed-by: Peter Wu Reviewed-by: João Valverde Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs --- CMakeLists.txt | 10 ++++++++++ CMakeOptions.txt | 1 + 2 files changed, 11 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 93ab94c5cf..50288264f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1107,8 +1107,18 @@ include(ConfigureChecks.cmake) include(TestBigEndian) test_big_endian(WORDS_BIGENDIAN) +# Global properties set_property(GLOBAL PROPERTY USE_FOLDERS ON) +if(ENABLE_CCACHE AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")) + # http://stackoverflow.com/a/24305849/82195 + find_program(CCACHE_EXECUTABLE ccache) + if(CCACHE_EXECUTABLE) + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_EXECUTABLE}") + set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCACHE_EXECUTABLE}") + endif() +endif() + # The top level checkAPIs target, add before subdirectory calls so it's avaiable to all add_custom_target(checkAPI) set_target_properties(checkAPI diff --git a/CMakeOptions.txt b/CMakeOptions.txt index f1aacd098f..41a8ab69cd 100644 --- a/CMakeOptions.txt +++ b/CMakeOptions.txt @@ -26,6 +26,7 @@ option(ENABLE_EXTRA_COMPILER_WARNINGS "Do additional compiler warnings (disables option(ENABLE_CODE_ANALYSIS "Enable the compiler's static analyzer if possible" OFF) option(ENABLE_ASAN "Enable AddressSanitizer (ASAN) for debugging (degrades performance)" OFF) option(ENABLE_CHECKHF_CONFLICT "Enable hf conflict check for debugging (start-up may be slower)" OFF) +option(ENABLE_CCACHE "Speed up compiling and linking using ccache if possible" OFF) # # Leave GTK2 the default on Windows, looks better than GTK3 -- cgit v1.2.3