Skip to content

Commit

Permalink
Allow CMake to generate compile_commands.json automatically in the bu…
Browse files Browse the repository at this point in the history
…ild dir

Some editors rely on clangd for autocompletion. In those cases clangd
will look for a compile_commands.json file in the root of the repository
to obtain the list of flags used for compilation and the INCLUDEPATH for
each file.
This commit allows CMake to automatically generate such file in the
designated build folder.
To enable clangd to use that file, simply link it in the root of the
project repository.
The link will be ignored by git.
  • Loading branch information
MuAlphaOmegaEpsilon committed Jan 30, 2023
1 parent f39a3b0 commit 4d5016e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)

# Generates a compile_commands.json in the build dir, link that to the repo
# root to enrich your IDE with clangd language server protocol functionalities
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Sanitizers
add_library(olive-sanitizers INTERFACE)
include(cmake/Sanitizers.cmake)
Expand Down

0 comments on commit 4d5016e

Please sign in to comment.