Skip to content

Commit

Permalink
[Shared] add a custom CMake target to copy compilation DB from build …
Browse files Browse the repository at this point in the history
…dir to source dir (#1177)

* add a custom cmake target to copy compilation DB from build dir to source dir

see https://clang.llvm.org/docs/JSONCompilationDatabase.html for further details

* gitignore compile_commands.json
  • Loading branch information
Razish authored Mar 5, 2024
1 parent 2a7c526 commit 62124e1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ pip-log.txt
## clangd
#############
.clangd
compile_commands.json

#############
## CLion
Expand All @@ -192,4 +193,4 @@ pip-log.txt
## CMake Builds
#############
[Bb]uild*/
cmake-build-*
cmake-build-*
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ endif()
#=============================================================================
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_SOURCE_DIR}/cmake/Modules")

if(CMAKE_EXPORT_COMPILE_COMMANDS)
add_custom_target(
copy-compile-commands ALL
${CMAKE_COMMAND} -E copy_if_different
${CMAKE_BINARY_DIR}/compile_commands.json
${CMAKE_CURRENT_LIST_DIR})
endif()

#=============================================================================
#
# Architecture/OS defines
Expand Down

0 comments on commit 62124e1

Please sign in to comment.