-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
75 lines (59 loc) · 2.18 KB
/
Makefile
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
72
73
74
75
# Copyright (c) Brandon Pacewic
# SPDX‑License‑Identifier: MIT
BUILD_DIR ?= build
CMAKE_GENERATOR ?= Unix Makefiles
BUILD_TESTS ?= ON # pass BUILD_TESTS=OFF to skip
BUILD_BENCH ?= OFF
BUILD_TOOLS ?= OFF
BUILD_TYPE ?= Debug # Release | RelWithDebInfo ...
JOBS ?= $(shell nproc 2>/dev/null || sysctl -n hw.ncpu)
CMAKE_FLAGS = \
-G "$(CMAKE_GENERATOR)" \
-DCMAKE_BUILD_TYPE=$(BUILD_TYPE) \
-DBUILD_TESTING=$(BUILD_TESTS) \
-DBUILD_BENCHMARKS=$(BUILD_BENCH) \
-DBUILD_TOOLS=$(BUILD_TOOLS) \
.PHONY: build test bench tools \
format clean distclean help
configure:
@mkdir -p "$(BUILD_DIR)"
@cmake -S . -B "$(BUILD_DIR)" $(CMAKE_FLAGS)
build: configure
@cmake --build "$(BUILD_DIR)" -- -j$(JOBS)
test: build
@ctest --test-dir "$(BUILD_DIR)" --output-on-failure
bench: BUILD_BENCH := ON
bench: build
@cmake --build "$(BUILD_DIR)" -j$(JOBS)
run-benchmarks: bench
@cmake --build "$(BUILD_DIR)" --target run_all_benchmarks -- -j$(JOBS)
bench-diff:
@python tools/scripts/compare_benchmarks.py
bench-out:
@python tools/scripts/output_benchmarks.py
tools: BUILD_TOOLS := ON
tools: build
format:
@clang-format -i -style=file $(shell git ls-files '*.hpp' '*.h' '*.cpp')
clean:
@cmake --build "$(BUILD_DIR)" --target clean || true
distclean:
@rm -rf "$(BUILD_DIR)"
help:
@echo "Targets:"
@echo " build - configure and build"
@echo " test - run ctest (RUN_TESTS=ON)"
@echo " bench - build & run benchmarks (BUILD_BENCH=ON)"
@echo " run-benchmarks - run all benchmarks"
@echo " bench-diff - compare the two most recent benchmark runs"
@echo " bench-out - output the most recent benchmark run"
@echo " tools - build project-defined tools (BUILD_TOOLS=ON)"
@echo " format - run clang-format on all source files"
@echo " clean - clean build artifacts"
@echo " distclean - clean entire build dir"
@echo ""
@echo "Knobs (override with VAR=value):"
@echo " BUILD_DIR, CMAKE_GENERATOR, BUILD_TYPE, JOBS"
@echo " BUILD_TESTS, BUILD_BENCH, BUILD_TOOLS"
# Default to help when running `make` without targets
.DEFAULT_GOAL := help