From ae114aea034babdc4fb88543150d069963181eda Mon Sep 17 00:00:00 2001 From: John Coyle Date: Wed, 9 Dec 2015 12:55:30 -0500 Subject: [PATCH] cmake: support ccache via a WITH_CCACHE build option When -DWITH_CCACHE=ON is specified, try to find and use ccache. Signed-off-by: John Coyle --- CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index cb41d3ea286..4ec6f3bdcbd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,18 @@ endif(NOT (CMAKE_MAJOR_VERSION LESS 3)) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/") +option(WITH_CCACHE "Build with ccache.") +if(WITH_CCACHE) + find_program(CCACHE_FOUND ccache) + if(CCACHE_FOUND) + message(STATUS "Building with ccache: ${CCACHE_FOUND}, CCACHE_DIR=$ENV{CCACHE_DIR}") + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) + set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) + else(CCACHE_FOUND) + message(FATAL_ERROR "Can't find ccache. Is it installed?") + endif(CCACHE_FOUND) +endif(WITH_CCACHE) + include_directories( ${PROJECT_BINARY_DIR}/src/include ${OFED_PREFIX}/include -- 2.47.3