-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
71 lines (60 loc) · 2.09 KB
/
Makefile
File metadata and controls
71 lines (60 loc) · 2.09 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
69
70
71
.PHONY: build-debug build-release clean-debug clean-release clean-all format test-debug test-release test help
# Default target
help:
@echo "Available targets:"
@echo " build-debug - Configure and build debug version in build/debug"
@echo " build-release - Configure and build release version in build/release"
@echo " test-debug - Build and run tests in debug mode"
@echo " test-release - Build and run tests in release mode"
@echo " test - Alias for test-debug"
@echo " clean-debug - Clean debug build directory"
@echo " clean-release - Clean release build directory"
@echo " clean-all - Clean both debug and release build directories"
@echo " format - Run clang-format on all source files"
# Detect number of CPU cores for parallel builds
NPROCS := 1
OS := $(shell uname -s)
ifeq ($(OS),Linux)
NPROCS := $(shell nproc)
endif
ifeq ($(OS),Darwin)
NPROCS := $(shell sysctl -n hw.ncpu)
endif
# Build debug version
build-debug:
@mkdir -p build/debug
@cd build/debug && cmake -DCMAKE_BUILD_TYPE=Debug ../..
@cd build/debug && $(MAKE) -j$(NPROCS)
# Build release version
build-release:
@mkdir -p build/release
@cd build/release && cmake -DCMAKE_BUILD_TYPE=Release ../..
@cd build/release && $(MAKE) -j$(NPROCS)
# Clean debug build
clean-debug:
@if [ -d build/debug ]; then \
cd build/debug && $(MAKE) clean; \
fi
# Clean release build
clean-release:
@if [ -d build/release ]; then \
cd build/release && $(MAKE) clean; \
fi
# Clean all builds
clean-all: clean-debug clean-release
@echo "All build directories cleaned"
# Format source code
format:
@echo "Formatting source files..."
@find src include tests -type f \( -name "*.cpp" -o -name "*.h" -o -name "*.hpp" \) -exec clang-format -i {} +
@echo "Formatting complete"
# Test debug build
test-debug: build-debug
@echo "Running tests in debug mode..."
@cd build/debug && ctest --output-on-failure --verbose
# Test release build
test-release: build-release
@echo "Running tests in release mode..."
@cd build/release && ctest --output-on-failure --verbose
# Default test target (debug)
test: test-debug