Generate a clang CompilationDatabase when running CMake
authorBenjamin Kramer <benny.kra@googlemail.com>
Wed, 16 Dec 2015 18:17:45 +0000 (18:17 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Wed, 16 Dec 2015 18:17:45 +0000 (18:17 +0000)
This generates a compile_commands.json file, which tells tools like
YouCompleteMe and clang_complete exactly how to build each source file.

Patch by Justin Lebar!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255789 91177308-0d34-0410-b5e6-96231b3b80d8

CMakeLists.txt

index c4ff8f3cd28bdb02ab20aa4ecf2efe79b460c485..3d2093fde6346ce95c0b9391a7ba0e8a7a6b7ad9 100644 (file)
@@ -86,6 +86,10 @@ set(CMAKE_MODULE_PATH
   "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
   )
 
+# Generate a CompilationDatabase (compile_commands.json file) for our build,
+# for use by clang_complete, YouCompleteMe, etc.
+set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
+
 option(LLVM_INSTALL_UTILS "Include utility binaries in the 'install' target." OFF)
 
 option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target." OFF)