Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -77,6 +77,26 @@ 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() + set(LLVM_BUILD_GLOBAL_ISEL OFF CACHE BOOL "Experimental: Build GlobalISel") if(LLVM_BUILD_GLOBAL_ISEL) add_definitions(-DLLVM_BUILD_GLOBAL_ISEL)