From b49a94fb83df3f9e0e81826692fb003a91129ae6 Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Thu, 14 Jan 2021 14:38:32 -0400 Subject: [PATCH] Export compile commands and use ccache by default --- CMakeLists.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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: