From 348ee6040731515030aead616ddf43aa347f11e5 Mon Sep 17 00:00:00 2001 From: Zach Nation Date: Sun, 14 Jan 2018 13:09:17 -0800 Subject: [PATCH] Generate compile_commands.json This file is used with tooling like IDEs to get autocompletion and other features that need to be aware of compile flags used on each source file. Seems to affect build performance minimally, and only takes a few MB of disk space when populated. I think it makes sense to turn it on globally so that it's there when tools/IDEs need it. --- .gitignore | 5 +++++ CMakeLists.txt | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/.gitignore b/.gitignore index 7d569be297..4377ff8977 100644 --- a/.gitignore +++ b/.gitignore @@ -94,3 +94,8 @@ deps/build doc/ /dummy.cpp + +# compile_commands.json - http://clang.llvm.org/docs/JSONCompilationDatabase.html +# generated by CMake + clang - Symlink debug/compile_commands.json (or release) +# to the root of the project for most tooling to work. This ignores the symlink. +/compile_commands.json diff --git a/CMakeLists.txt b/CMakeLists.txt index 02e554a46b..7ff6c1958e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,10 @@ cmake_policy(SET CMP0046 OLD) cmake_policy(SET CMP0042 NEW) endif() +# Generate a compilation database for use with automated tools like IDE/editor +# plugins. See http://clang.llvm.org/docs/JSONCompilationDatabase.html +set( CMAKE_EXPORT_COMPILE_COMMANDS ON ) + # Determine where additional Turi specific cmake modules are # defined set(DEPS_CMAKE ${CMAKE_SOURCE_DIR}/deps/cmake)