Skip to content

Commit

Permalink
cmake: always generate compile commands
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Riolku committed Nov 24, 2023
1 parent 4bb9670 commit 417848b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 417848b

Please sign in to comment.