From 720513c215983da8a21f7eceb1cb2211f9503c12 Mon Sep 17 00:00:00 2001 From: Keenan Gugeler Date: Fri, 24 Nov 2023 00:46:24 -0500 Subject: [PATCH] cmake: always generate compile commands Generating compilation commands consumes negligible time on our scale of build. DuckDB enables the generation by [default][1]. Also, this automatic generation eases integrations with editors and tools like clang-tidy. [1]: https://github.com/duckdb/duckdb/blob/173a690d18058ca1021b3241653eec27d07eb2df/CMakeLists.txt#L23 --- CMakeLists.txt | 1 + Makefile | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a667e36fa..3ded717107 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,7 @@ set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED TRUE) set(CMAKE_CXX_VISIBILITY_PRESET hidden) set(CMAKE_C_VISIBILITY_PRESET hidden) +set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE) set(CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS TRUE) set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_VISIBILITY_INLINES_HIDDEN ON) diff --git a/Makefile b/Makefile index f364ed00e9..32a7b872a1 100644 --- a/Makefile +++ b/Makefile @@ -157,17 +157,15 @@ shell: # Clang-related tools and checks -clangd: - $(call config-cmake-release, -DCMAKE_EXPORT_COMPILE_COMMANDS=1) # Must build the java native header to avoid missing includes. Pipe character # `|` ensures these targets build in this order, even in the presence of # parallelism. -tidy: | allconfig clangd java_native_header +tidy: | allconfig java_native_header run-clang-tidy -p build/release -quiet -j $(NUM_THREADS) \ "^$(realpath src)|$(realpath tools)/(?!shell/linenoise.cpp)|$(realpath examples)" -clangd-diagnostics: | allconfig clangd java_native_header +clangd-diagnostics: | allconfig java_native_header find src -name *.h -or -name *.cpp | xargs \ ./scripts/get-clangd-diagnostics.py --compile-commands-dir build/release \ -j $(NUM_THREADS) --instances $(CLANGD_DIAGNOSTIC_INSTANCES)