diff --git a/CMakeLists.txt b/CMakeLists.txt index d74da72..18de94a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,16 @@ + +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +find_program(CCACHE_PROGRAM ccache) +if(CCACHE_PROGRAM) + foreach(lang C CXX) + if(NOT DEFINED CMAKE_${lang}_COMPILER_LAUNCHER AND NOT CMAKE_${lang}_COMPILER MATCHES ".*/ccache") + message(STATUS "Enabling ccache for ${lang}") + set(CMAKE_${lang}_COMPILER_LAUNCHER ${CCACHE_PROGRAM} CACHE STRING "") + endif() + endforeach() +endif() + cmake_minimum_required(VERSION 3.7) # Has to be set before `project()`, and ignored on non-macos: