Skip to content

Comments

Generate compile_commands.json by default#9763

Merged
areusch merged 3 commits intoapache:mainfrom
driazati:cc
Jan 7, 2022
Merged

Generate compile_commands.json by default#9763
areusch merged 3 commits intoapache:mainfrom
driazati:cc

Conversation

@driazati
Copy link
Member

@driazati driazati commented Dec 16, 2021

This is low overhead (it only affects the make-generation step, not the actual build) and makes developer tooling like clangd work much better, so we should have it on by default instead of off (which is CMake's default). If necessary, it can be disabled with

cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=0 ...

or adding this to config.cmake

set(CMAKE_EXPORT_COMPILE_COMMANDS OFF)

If CMake is run from a subproject, this does nothing and leaves it to the parent to configure. For example, this does not generate compile_commands.json by default:

cmake_minimum_required(VERSION 2.0 FATAL_ERROR)
project(test)
add_subdirectory(tvm)
add_executable(test test.cpp)

cc @areusch

@driazati driazati requested a review from a team as a code owner December 16, 2021 23:57
@junrushao
Copy link
Member

Yeah usually we need compile_commands.json by default, so I'm in favor of doing so. Not a cmake expert, just curious, is it better to put this in CMakeList.txt or config.cmake? What if TVM is used as a CMake submodule by other projects?

@driazati
Copy link
Member Author

driazati commented Dec 17, 2021

I think it's better in CMakeLists.txt since everyone will get it automatically rather than having to update any cmake configs they use, but the point about avoiding messing with parent projects is good. It looks like that can be detected so it can avoid setting anything in that case, I will follow up with a fix soon

@driazati driazati marked this pull request as draft December 17, 2021 17:34
@driazati driazati marked this pull request as ready for review December 17, 2021 18:13
@junrushao
Copy link
Member

Thank you @driazati for the explanation!!

This is low overhead (it only affects the make-generation step, not the actual build) and makes developer tooling like clangd work much better, so we should have it on by default instead of off (which is CMake's default). If necessary, it can be disabled with

```bash
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=0 ...
```
Copy link
Contributor

@areusch areusch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, this makes sense. one question for you

Co-authored-by: Andrew Reusch <areusch@gmail.com>
@driazati driazati requested a review from areusch January 4, 2022 18:03
@areusch areusch merged commit 51803ed into apache:main Jan 7, 2022
ylc pushed a commit to ylc/tvm that referenced this pull request Feb 16, 2022
* Generate compile_commands.json by default

This is low overhead (it only affects the make-generation step, not the actual build) and makes developer tooling like clangd work much better, so we should have it on by default instead of off (which is CMake's default). If necessary, it can be disabled with

```bash
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=0 ...
```

* Add skip when run in a subproject

* Update CMakeLists.txt

Co-authored-by: Andrew Reusch <areusch@gmail.com>

Co-authored-by: driazati <driazati@users.noreply.github.com>
Co-authored-by: Andrew Reusch <areusch@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants