diff --git a/CMakeLists.txt b/CMakeLists.txt index c9276b376f36..1854e53cf94b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,6 +101,26 @@ if(LLVM_PARALLEL_COMPILE_JOBS) endif() endif() +# Build llvm with ccache if the package is present +set(LLVM_CCACHE_BUILD OFF CACHE BOOL "Set to ON for a ccache enabled build") +if(LLVM_CCACHE_BUILD) + find_program(CCACHE_PROGRAM ccache) + if(CCACHE_PROGRAM) + set(LLVM_CCACHE_SIZE "" CACHE STRING "Size of ccache") + set(LLVM_CCACHE_DIR "" CACHE STRING "Directory to keep ccached data") + set(CCACHE_PROGRAM "CCACHE_CPP2=yes CCACHE_HASHDIR=yes ${CCACHE_PROGRAM}") + if (LLVM_CCACHE_SIZE) + set(CCACHE_PROGRAM "CCACHE_SIZE=${LLVM_CCACHE_SIZE} ${CCACHE_PROGRAM}") + endif() + if (LLVM_CCACHE_DIR) + set(CCACHE_PROGRAM "CCACHE_DIR=${LLVM_CCACHE_DIR} ${CCACHE_PROGRAM}") + endif() + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_PROGRAM}) + else() + message(FATAL_ERROR "Unable to find the program ccache. Set LLVM_CCACHE_BUILD to OFF") + endif() +endif() + option(LLVM_BUILD_GLOBAL_ISEL "Experimental: Build GlobalISel" OFF) if(LLVM_BUILD_GLOBAL_ISEL) add_definitions(-DLLVM_BUILD_GLOBAL_ISEL)