[PATCH] buildsystem: add generation possibilty of compile_commands.json for cmake
Florian Eckert
fe at dev.tdt.de
Wed Mar 5 05:22:11 PST 2025
Redmine-patch-id: 9284
The cmake compilation tool offers the option of creating a
'compile_commands.json' file. This file is mainly used in C and C++
development environments to provide information about how each source file
in a project is compiled.
This is especially useful for LSP during development. LSP stands for
Language Server Protocol. It is a protocol used to enable communication
between development tools (like text editors and IDEs) and language servers
that provide language-specific features.
The file 'compile_commands.json' is only generated in the compilation
directory of the package, if the compilation command is executed with 'V=s'.
Signed-off-by: Florian Eckert <fe at dev.tdt.de>
---
include/cmake.mk | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/include/cmake.mk b/include/cmake.mk
index f59410c2f3..2c9c156c5e 100644
--- a/include/cmake.mk
+++ b/include/cmake.mk
@@ -15,6 +15,10 @@ ifneq ($(findstring c,$(OPENWRT_VERBOSE)),)
HOST_MAKE_FLAGS+=VERBOSE=1
endif
+ifneq ($(findstring s,$(OPENWRT_VERBOSE)),)
+ CMAKE_OPTIONS += -DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE
+endif
+
CMAKE_BINARY_DIR = $(PKG_BUILD_DIR)$(if $(CMAKE_BINARY_SUBDIR),/$(CMAKE_BINARY_SUBDIR))
CMAKE_SOURCE_DIR = $(PKG_BUILD_DIR)$(if $(CMAKE_SOURCE_SUBDIR),/$(CMAKE_SOURCE_SUBDIR))
HOST_CMAKE_SOURCE_DIR = $(HOST_BUILD_DIR)$(if $(CMAKE_SOURCE_SUBDIR),/$(CMAKE_SOURCE_SUBDIR))
--
2.39.5
More information about the openwrt-devel
mailing list