TheLartians / ModernCppStarter

🚀 Kick-start your C++! A template for modern C++ projects using CMake, CI, code coverage, clang-format, reproducible dependency management and much more.
https://thelartians.github.io/ModernCppStarter
The Unlicense
4.33k stars 381 forks source link

Added compile_commands.json #170

Open barakdiker123 opened 1 year ago

barakdiker123 commented 1 year ago

For using clangd we need the compile database of compile_commands.json I think It would be a nice addition for this repo

wujiang commented 1 year ago

Love the idea! But I think it's better to add that line in tools.cmake.

--- a/cmake/tools.cmake
+++ b/cmake/tools.cmake
@@ -6,6 +6,8 @@ if(NOT PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
   return()
 endif()

+set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
+
 include(${CMAKE_CURRENT_LIST_DIR}/CPM.cmake)