Skip to content
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

[C++] Export compile commands database by default #36124

Closed
bkietz opened this issue Jun 16, 2023 · 4 comments · Fixed by #37426
Closed

[C++] Export compile commands database by default #36124

bkietz opened this issue Jun 16, 2023 · 4 comments · Fixed by #37426

Comments

@bkietz
Copy link
Member

bkietz commented Jun 16, 2023

Describe the enhancement requested

CMakePresets.json does not export compile commands by default. The relevant option is "CMAKE_EXPORT_COMPILE_COMMANDS": "ON", and produces a file compile_commands.json which is used by clang tooling. The file is not huge; about 1MB. IMHO it'd be worthwhile to enable this by default so that developers always have access to it without needing to regenerate their cmake build dir; language servers and other tooling can be silently disabled without the compile commands database. See also discussion here

Component(s)

C++

@lidavidm
Copy link
Member

CMake also reads this from an environment variable (in 3.17+), so developers can just individually set that in their shell configuration and get it for all CMake projects.

@zeroshade
Copy link
Member

I'm gonna +1 this issue as when I was setting up my tooling it took a bit of research before I found the CMAKE_EXPORT_COMPILE_COMMANDS option and it would have been much easier if it just exported the compile commands by default.

@js8544
Copy link
Collaborator

js8544 commented Jun 16, 2023

+1, whenever I set up a new dev environment I'll need to google this variable because it's hard to remember the name verbatim. Would be nice to have it in the preset.

@pitrou
Copy link
Member

pitrou commented Aug 22, 2023

This sounds reasonable, do you want to do it @bkietz ?

@bkietz bkietz self-assigned this Aug 28, 2023
kou pushed a commit that referenced this issue Aug 28, 2023
`CMakePresets.json` does not export `compile_commands.json` by default, which is used by all clang tooling. Adding it as a default ensures that new developers (or any others who forget to specifically specify the option) will still be able to use their language servers without regenerating the cmake build dir.

The relevant option is `"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"`, and causes generation of a ~1MB file at build time.
* Closes: #36124

Authored-by: Benjamin Kietzman <bengilgit@gmail.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
@kou kou added this to the 14.0.0 milestone Aug 28, 2023
loicalleyne pushed a commit to loicalleyne/arrow that referenced this issue Nov 13, 2023
…#37426)

`CMakePresets.json` does not export `compile_commands.json` by default, which is used by all clang tooling. Adding it as a default ensures that new developers (or any others who forget to specifically specify the option) will still be able to use their language servers without regenerating the cmake build dir.

The relevant option is `"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"`, and causes generation of a ~1MB file at build time.
* Closes: apache#36124

Authored-by: Benjamin Kietzman <bengilgit@gmail.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants