Skip to content

Commit

Permalink
Generate compile_commands.json by default (#9763)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

Co-authored-by: driazati <[email protected]>
Co-authored-by: Andrew Reusch <[email protected]>
  • Loading branch information
3 people authored Jan 7, 2022
1 parent d3a83b5 commit 51803ed
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@ include_directories(SYSTEM ${PICOJSON_PATH})
set(TVM_LINKER_LIBS "")
set(TVM_RUNTIME_LINKER_LIBS "")


# Check if this is being run on its own or as a subdirectory for another project
# If we update to CMake 2.21+, we can use PROJECT_IS_TOP_LEVEL instead
get_directory_property(IS_SUBPROJECT PARENT_DIRECTORY)

if(NOT IS_SUBPROJECT AND NOT DEFINED "${CMAKE_EXPORT_COMPILE_COMMANDS}")
# If not set manually, change the default to ON
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
endif()

# Generic compilation options
if(MSVC)
add_definitions(-DWIN32_LEAN_AND_MEAN)
Expand Down

0 comments on commit 51803ed

Please sign in to comment.