Skip to content

Commit e71f092

Browse files
feat(build): support clangd compile commands (#127)
1 parent 00b21b3 commit e71f092

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ __pycache__/
66
.vscode/
77
/build/
88
/out/
9+
compile_commands.json

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ BUILD_TESTS ?= ON # pass BUILD_TESTS=OFF to skip
77
BUILD_BENCH ?= OFF
88
BUILD_TOOLS ?= OFF
99
BUILD_TYPE ?= Debug # Release | RelWithDebInfo ...
10+
COMPILE_COMMANDS ?= ON
1011
JOBS ?= $(shell nproc 2>/dev/null || sysctl -n hw.ncpu)
1112

1213
CMAKE_FLAGS = \
@@ -15,13 +16,17 @@ CMAKE_FLAGS = \
1516
-DBUILD_TESTING=$(BUILD_TESTS) \
1617
-DBUILD_BENCHMARKS=$(BUILD_BENCH) \
1718
-DBUILD_TOOLS=$(BUILD_TOOLS) \
19+
-DCMAKE_EXPORT_COMPILE_COMMANDS=$(COMPILE_COMMANDS)
1820

1921
.PHONY: build test bench tools \
2022
format clean distclean help
2123

2224
configure:
2325
@mkdir -p "$(BUILD_DIR)"
2426
@cmake -S . -B "$(BUILD_DIR)" $(CMAKE_FLAGS)
27+
ifeq ($(COMPILE_COMMANDS),ON)
28+
@ln -sf "$(BUILD_DIR)/compile_commands.json" compile_commands.json
29+
endif
2530

2631
build: configure
2732
@cmake --build "$(BUILD_DIR)" -- -j$(JOBS)
@@ -53,6 +58,9 @@ clean:
5358

5459
distclean:
5560
@rm -rf "$(BUILD_DIR)"
61+
ifeq ($(COMPILE_COMMANDS),ON)
62+
@rm -f compile_commands.json
63+
endif
5664

5765
help:
5866
@echo "Targets:"

0 commit comments

Comments
 (0)