-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate compile_commands.json for clangd #381
base: development
Are you sure you want to change the base?
Conversation
modified: src/particles/elements/diagnostics/openPMD.cpp
Co-authored-by: Axel Huebl <[email protected]>
Per the docs:
|
Clang on Windows seems happy but MSVC is not yet:
Actually, how does this handle MultiConfig generators? |
CMakeLists.txt
Outdated
add_custom_target( | ||
copy-compile-commands ALL | ||
${CMAKE_COMMAND} -E copy_if_different | ||
${CMAKE_BINARY_DIR}/compile_commands.json ${PROJECT_SOURCE_DIR}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has to be guarded for all build generators that are not GNUmake or Ninja:
https://cmake.org/cmake/help/latest/variable/CMAKE_EXPORT_COMPILE_COMMANDS.html
Note
This option is implemented only by Makefile Generators and Ninja Generators. It is ignored on other generators.
This option currently does not work well in combination with the UNITY_BUILD target property or the CMAKE_UNITY_BUILD variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a guard to only generate compile_commands.json
for Unix Makefiles
and Ninja
generators.
I wonder if they mean they also look recursively into directories inside source, e.g., in Generally, I do not see how this can work with multi-config generators at all - every config needs its own Clion's IDE solves this a bit smarter, they are aware of the build configs, generate a file in the respective build directory and run clangd on that. Is there a way in your IDE to configure this equally? Which IDE are you using? Or did you configure clangd manually to work with your toolchain? |
d21853f
to
8e7cd3c
Compare
…inja generators only modified: CMakeLists.txt
bc25600
to
9c98645
Compare
Upon further thought, I agree that placing it in the build directory is a better solution than placing it in the source directory. I've removed the command that copies it to the source directory. |
modified: .gitignore modified: CMakeLists.txt
4af2880
to
a3da9fa
Compare
I'm using
Maybe there is, but I'm not aware of it. If we place |
compile_commands.json
is used byclangd
LSP to interpret the source files