-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
68 lines (54 loc) · 1.52 KB
/
Copy pathMakefile
File metadata and controls
68 lines (54 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
.PHONY: all setup build clean rebuild check-deps
BUILD_DIR := build
BUILD_TYPE ?= Debug
all: build
check-deps:
@command -v cmake >/dev/null 2>&1 || { \
echo "Error: CMake is not installed."; \
echo "Install it with: sudo apt update && sudo apt install cmake"; \
exit 1; \
}
@command -v ninja >/dev/null 2>&1 || { \
echo "Error: Ninja is not installed."; \
echo "Install it with: sudo apt update && sudo apt install ninja-build"; \
exit 1; \
}
@command -v c++ >/dev/null 2>&1 || { \
echo "Error: A C++ compiler is not installed."; \
echo "Install it with: sudo apt update && sudo apt install build-essential"; \
exit 1; \
}
setup: check-deps
@command -v git >/dev/null 2>&1 || { \
echo "Error: Git is not installed."; \
echo "Install it with: sudo apt update && sudo apt install git"; \
exit 1; \
}
@echo "Initializing Git submodules..."
git submodule update --init --recursive
@echo "Configuring CDSL..."
cmake -S . \
-B $(BUILD_DIR) \
-G Ninja \
-DCMAKE_BUILD_TYPE=$(BUILD_TYPE) \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
@ln -sf $(BUILD_DIR)/compile_commands.json compile_commands.json
format:
find src include -type f \( \
-name '*.c' -o \
-name '*.h' -o \
-name '*.cpp' -o \
-name '*.hpp' \
\) -exec clang-format -i {} +
build: check-deps
@if [ ! -d "$(BUILD_DIR)" ]; then \
$(MAKE) setup; \
fi
@echo "Building CDSL..."
cmake --build $(BUILD_DIR) --parallel
clean:
@echo "Cleaning build files..."
rm -rf $(BUILD_DIR) compile_commands.json
rebuild: clean
$(MAKE) setup
$(MAKE) build